From 0a64953179953aa0386d93e199d56019a796869a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 10:38:52 +0000 Subject: [PATCH 01/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 9eef4fb..3aa21da 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,8 @@ "@stdlib/array-base-resolve-getter": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2" + "@stdlib/utils-define-read-write-accessor": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.2", @@ -85,4 +86,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 571d79272dd4c94b26f4db3f208778711de0d535 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 10:39:38 +0000 Subject: [PATCH 02/45] 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 | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 49 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 192 - package.json | 65 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 229 - 43 files changed, 4866 insertions(+), 4190 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index cfd0f63..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var y=function(s,i){return function(){return i||s((i={exports:{}}).exports,i),i.exports}};var g=y(function(J,p){ -var o=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),N=require('@stdlib/utils-define-read-write-accessor/dist'),d=require('@stdlib/array-base-resolve-getter/dist'),m=require('@stdlib/array-base-accessors/dist'),O=require('@stdlib/array-base-copy/dist');function k(s,i){var a,c,v,u,f,e;if(u=s.length,u<1)return[];if(a=d(s),f=a(s,0).length,f<1)return[];c=O(i);function h(r){var t=m(r).accessors;return o(this,"_arr",r),o(this,"_get",t[0]),o(this,"_set",t[1]),this}for(e=0;e} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerableReadOnly( this, '_arr', arr );\n\t\tsetNonEnumerableReadOnly( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerableReadOnly( this, '_set', acc[ 1 ] );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ) ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAWpB,SAASO,EAAOR,EAAM,CACrB,IAAIS,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAA0B,KAAM,OAAQM,CAAI,EAC5CN,EAA0B,KAAM,OAAQe,EAAK,CAAE,CAAE,EACjDf,EAA0B,KAAM,OAAQe,EAAK,CAAE,CAAE,EAC1C,IACR,CAGA,IAAMF,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAQhF,IAJAb,EAA0Bc,EAAM,UAAW,SAAUI,CAAO,EAG5DR,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,CAAE,CAAE,EAEvC,OAAOH,EASP,SAASM,EAAUG,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,OAAO,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASF,EAAUE,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASJ,GAAS,CACjB,IAAIR,EACAa,EACAV,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBU,EAAId,EAAMI,CAAE,EACZH,EAAKa,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOb,CACR,CACD,CAKAX,EAAO,QAAUM,ICrIjB,IAAImB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "toJSON", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..36ff624 --- /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-only-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function i(i,o){var d,a,h,m,f,u;if((m=i.length)<1)return[];if((f=(d=e(i))(i,0).length)<1)return[];function c(r){var e=s(r).accessors;return t(this,"_arr",r),t(this,"_get",e[0]),t(this,"_set",e[1]),this}for(a=n(o),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerableReadOnly( this, '_arr', arr );\n\t\tsetNonEnumerableReadOnly( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerableReadOnly( this, '_set', acc[ 1 ] );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ) ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerableReadOnly","this","copy","setReadWriteAccessor","prototype","getValue","setValue","k","push","idx","_get","_arr","value","_set"],"mappings":";;ggBA0EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,IADAF,GADAJ,EAAOO,EAAeT,IACZA,EAAK,GAAIQ,QACV,EACR,MAAO,GAcR,SAASE,EAAOV,GACf,IAAIW,EAAMC,EAAWZ,GAAMY,UAI3B,OAHAC,EAA0BC,KAAM,OAAQd,GACxCa,EAA0BC,KAAM,OAAQH,EAAK,IAC7CE,EAA0BC,KAAM,OAAQH,EAAK,IACtCG,IACP,CAGD,IApBAX,EAAOY,EAAMd,GAoBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBS,EAAsBN,EAAMO,UAAWd,EAAMI,GAAKW,EAAUX,GAAKY,EAAUZ,IAQ5E,IAJAM,EAA0BH,EAAMO,UAAW,UAyD3C,WACC,IAAIb,EACAgB,EACAb,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAIF,EAAGE,IAEnBH,EADAgB,EAAIjB,EAAMI,IACCO,KAAMM,GAElB,OAAOhB,CACP,IAjEDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIiB,KAAM,IAAIX,EAAOR,EAAMF,EAAKO,KAEjC,OAAOH,EASP,SAASc,EAAUI,GAClB,OAQA,WACC,OAAOR,KAAKS,KAAMT,KAAKU,KAAMF,EAC7B,CACD,CASD,SAASH,EAAUG,GAClB,OAQA,SAAcG,GACbX,KAAKY,KAAMZ,KAAKU,KAAMF,EAAKG,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 66cbced..0000000 --- a/lib/main.js +++ /dev/null @@ -1,192 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @returns {Datum} datum instance - */ - function Datum( arr ) { - var acc = accessors( arr ).accessors; - setNonEnumerableReadOnly( this, '_arr', arr ); - setNonEnumerableReadOnly( this, '_get', acc[ 0 ] ); - setNonEnumerableReadOnly( this, '_set', acc[ 1 ] ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ) ) ); - } - return out; - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < M; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 3aa21da..2e15dd2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Convert nested arrays to composite views.", "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,42 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.2", - "@stdlib/array-base-filled2d-by": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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", "utilities", @@ -86,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..577bcef --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 01ffecf..0000000 --- a/test/test.js +++ /dev/null @@ -1,229 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); From a319df9a94e921ff1f82312004e19b17f5db322f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 22:35:41 +0000 Subject: [PATCH 03/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c4c5a5c..05787cb 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2" + "@stdlib/utils-define-read-write-accessor": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.2", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 91ca07d8b71e4ebd108a3c86490609e7aba20fb2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 22:36:01 +0000 Subject: [PATCH 04/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 36ff624..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-only-property@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function i(i,o){var d,a,h,m,f,u;if((m=i.length)<1)return[];if((f=(d=e(i))(i,0).length)<1)return[];function c(r){var e=s(r).accessors;return t(this,"_arr",r),t(this,"_get",e[0]),t(this,"_set",e[1]),this}for(a=n(o),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerableReadOnly( this, '_arr', arr );\n\t\tsetNonEnumerableReadOnly( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerableReadOnly( this, '_set', acc[ 1 ] );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ) ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerableReadOnly","this","copy","setReadWriteAccessor","prototype","getValue","setValue","k","push","idx","_get","_arr","value","_set"],"mappings":";;ggBA0EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,IADAF,GADAJ,EAAOO,EAAeT,IACZA,EAAK,GAAIQ,QACV,EACR,MAAO,GAcR,SAASE,EAAOV,GACf,IAAIW,EAAMC,EAAWZ,GAAMY,UAI3B,OAHAC,EAA0BC,KAAM,OAAQd,GACxCa,EAA0BC,KAAM,OAAQH,EAAK,IAC7CE,EAA0BC,KAAM,OAAQH,EAAK,IACtCG,IACP,CAGD,IApBAX,EAAOY,EAAMd,GAoBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBS,EAAsBN,EAAMO,UAAWd,EAAMI,GAAKW,EAAUX,GAAKY,EAAUZ,IAQ5E,IAJAM,EAA0BH,EAAMO,UAAW,UAyD3C,WACC,IAAIb,EACAgB,EACAb,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAIF,EAAGE,IAEnBH,EADAgB,EAAIjB,EAAMI,IACCO,KAAMM,GAElB,OAAOhB,CACP,IAjEDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIiB,KAAM,IAAIX,EAAOR,EAAMF,EAAKO,KAEjC,OAAOH,EASP,SAASc,EAAUI,GAClB,OAQA,WACC,OAAOR,KAAKS,KAAMT,KAAKU,KAAMF,EAC7B,CACD,CASD,SAASH,EAAUG,GAClB,OAQA,SAAcG,GACbX,KAAKY,KAAMZ,KAAKU,KAAMF,EAAKG,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 577bcef..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 49bfb774c5be07993bde5134fef9d3edd31e21e6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 22:36:18 +0000 Subject: [PATCH 05/45] 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 | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 60 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 291 -- 43 files changed, 4866 insertions(+), 4290 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 43b2eb7..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,n,v,r;if(n=i.length,n<1)return[];if(u=O(i),v=u(i,0).length,v<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..98df0c5 --- /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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if((m=(a=s(o))(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,IADAF,GADAJ,EAAOO,EAAeT,IACZA,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAIF,EAAGE,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 e7fe9c9..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < M; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 05787cb..2e15dd2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.2", - "@stdlib/array-base-filled2d-by": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..27622f8 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index ee8b151..0000000 --- a/test/test.js +++ /dev/null @@ -1,291 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); From 89d1d58625ee51b6c380fbbd50c2d1e341217747 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 23:48:07 +0000 Subject: [PATCH 06/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c4c5a5c..05787cb 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2" + "@stdlib/utils-define-read-write-accessor": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.2", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1ec64099be649cbdd0d743b39a1ff043bd1a0b9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 23:48:24 +0000 Subject: [PATCH 07/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 98df0c5..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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if((m=(a=s(o))(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < M; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,IADAF,GADAJ,EAAOO,EAAeT,IACZA,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAIF,EAAGE,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 27622f8..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5e65d6e2d4d1aa7784242fa4afb03a0706c0adca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 28 Jul 2025 23:48:52 +0000 Subject: [PATCH 08/45] 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 | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 63 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 43 files changed, 4866 insertions(+), 4326 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a5e20a2 --- /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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 05787cb..2e15dd2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.2", - "@stdlib/array-base-filled2d-by": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..27622f8 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From 9b351c70a5d8d7679f8159366efecfd4c0824140 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 Aug 2025 00:39:18 +0000 Subject: [PATCH 09/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c4c5a5c..05787cb 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2" + "@stdlib/utils-define-read-write-accessor": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.2", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0c5138bfd131965c5e1ea3b21e2ebadf84cc1aa6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 Aug 2025 00:40:13 +0000 Subject: [PATCH 10/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a5e20a2..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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 27622f8..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6aca7112322412ba305a2fe2dab5f89e06d250dd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 Aug 2025 00:40:36 +0000 Subject: [PATCH 11/45] 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 | 63 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4866 insertions(+), 4327 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 69c4add..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-08-18T00:38:48.486Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..a5e20a2 --- /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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 05787cb..2e15dd2 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.2", - "@stdlib/array-base-filled2d-by": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..27622f8 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From abb24225bd3f2e74360dfa593a0745f59fa37fd9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:39:07 +0000 Subject: [PATCH 12/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6b1ecc6..e1c8009 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.2", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2" + "@stdlib/utils-define-read-write-accessor": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.3", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4b1caa80c1a8279ba52ca8eac9d416a37b0639c2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:39:20 +0000 Subject: [PATCH 13/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a5e20a2..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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 27622f8..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4164a0521fb0a934a9faf3f73aa35e3d86757544 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:39:43 +0000 Subject: [PATCH 14/45] 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 | 63 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 43 files changed, 4866 insertions(+), 4431 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..4f9fbc3 --- /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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index e1c8009..ef11392 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/utils-define-read-write-accessor": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.3", - "@stdlib/array-base-filled2d-by": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..27622f8 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From 730be496984f116861bd96abb5cbaff7f796847a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:58:23 +0000 Subject: [PATCH 15/45] 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 2873c70..4c6de1c 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.0-esm/index.mjs'; ``` #### nested2views( arr, fields ) @@ -113,7 +113,7 @@ Each element in the returned array is a class instance having prototype properti var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import filled2dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled2d-by@esm/index.mjs'; -import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.0-esm/index.mjs'; var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); var fields = [ 'x', 'y' ]; From 62fcc3e3a32df376fb00c77a3c2fb867750619d2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:58:24 +0000 Subject: [PATCH 16/45] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c6de1c..c587e07 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-base-nested2views/tags). For example, + ```javascript import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.0-esm/index.mjs'; ``` @@ -113,7 +118,7 @@ Each element in the returned array is a class instance having prototype properti var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import filled2dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled2d-by@esm/index.mjs'; -import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.0-esm/index.mjs'; +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); var fields = [ 'x', 'y' ]; From 55f60ccc8b9009914f9edfaf5a6c6916a7945293 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 01:31:49 +0000 Subject: [PATCH 17/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c7d5971..53c4306 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" + "@stdlib/utils-define-read-write-accessor": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.3", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6029c07478cf0ce19a1c35f6a11a7f3786ab7913 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 02:03:44 +0000 Subject: [PATCH 18/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 4f9fbc3..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-only-property@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.2-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 27622f8..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 144cb8bfba9cb479a1e9f9d3590cac0e22c12d43 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Feb 2026 02:04:07 +0000 Subject: [PATCH 19/45] 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 | 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 | 63 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4866 insertions(+), 4432 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 3699688..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-02T01:21:39.792Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..dcb3969 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 53c4306..ef11392 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/array-base-copy": "^0.2.2", - "@stdlib/array-base-resolve-getter": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.3", - "@stdlib/array-base-filled2d-by": "^0.2.2", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-plain-object": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^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", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..d01283b --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From e1e946e49809de2e944aa9ee21474ab16ba9a27f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:02:07 +0000 Subject: [PATCH 20/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 2adef21..b684c38 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" + "@stdlib/utils-define-read-write-accessor": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.4", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 85862e7a831f75af7870c35ea176b805e9306ec8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:53:24 +0000 Subject: [PATCH 21/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index dcb3969..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.2-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index d01283b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b4cc647d33da8c817d714e5ec488ef437ce01fc3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:53:48 +0000 Subject: [PATCH 22/45] 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 | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 43 files changed, 4866 insertions(+), 4434 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..9b7ffee --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index b684c38..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.2", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.2", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b0f943d --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From ae58cba32ae5a7da41a9a25b07fbbcc91a8d3fdd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:03:26 +0000 Subject: [PATCH 23/45] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ae4f592..5a69b0f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ limitations under the License. ## Usage ```javascript -import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.1-esm/index.mjs'; ``` #### nested2views( arr, fields ) @@ -113,7 +113,7 @@ Each element in the returned array is a class instance having prototype properti var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import filled2dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled2d-by@esm/index.mjs'; -import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.1-esm/index.mjs'; var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); var fields = [ 'x', 'y' ]; From 984aad8af46395fad8e0a880772e6e15a06841fd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 01:03:27 +0000 Subject: [PATCH 24/45] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5a69b0f..c2c1c6b 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,11 @@ limitations under the License. ## Usage +```javascript +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; +``` +The previous example will load the latest bundled code from the esm branch. Alternatively, you may load a specific version by loading the file from one of the [tagged bundles](https://github.com/stdlib-js/array-base-nested2views/tags). For example, + ```javascript import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.1-esm/index.mjs'; ``` @@ -113,7 +118,7 @@ Each element in the returned array is a class instance having prototype properti var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform' ).factory; import filled2dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled2d-by@esm/index.mjs'; -import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@v0.1.1-esm/index.mjs'; +import nested2views from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nested2views@esm/index.mjs'; var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); var fields = [ 'x', 'y' ]; From 1cae407402bc7991235ad75550c8d035ab6ecb38 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 03:06:14 +0000 Subject: [PATCH 25/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 973db5c..71248d4 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" + "@stdlib/utils-define-read-write-accessor": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.4", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 48612db3bc3ed8b2fc2c5ad723b3797ca8122716 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 04:26:00 +0000 Subject: [PATCH 26/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9b7ffee..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b0f943d..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c792f2c6df89296be770cfcd5c780a9de2572510 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Feb 2026 04:26:20 +0000 Subject: [PATCH 27/45] 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 | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4866 insertions(+), 4435 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 81a768c..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-16T02:20:36.779Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..33e3432 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 71248d4..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..49aef28 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From 12f0565826237a0d972c6581a9db508e03d7fd51 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Mar 2026 03:28:40 +0000 Subject: [PATCH 28/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 973db5c..71248d4 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" + "@stdlib/utils-define-read-write-accessor": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.4", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a9a6718e39302621b50a2195bf0f7f43baacdf27 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Mar 2026 05:25:50 +0000 Subject: [PATCH 29/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 33e3432..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 49aef28..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 44326a8191528fe15675802a2e4a5dbdd0638657 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 2 Mar 2026 05:26:08 +0000 Subject: [PATCH 30/45] 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 | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4866 insertions(+), 4435 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1a461b2..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-03-02T02:29:05.227Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..33e3432 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 71248d4..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..49aef28 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From 807a75196750d8d94e29b1e17e8659d85e0b59aa Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Apr 2026 03:53:46 +0000 Subject: [PATCH 31/45] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 973db5c..71248d4 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "@stdlib/types": "^0.4.3", "@stdlib/utils-define-nonenumerable-property": "^0.2.3", "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" + "@stdlib/utils-define-read-write-accessor": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, "devDependencies": { "@stdlib/array-base-filled2d": "^0.2.4", @@ -86,4 +87,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 041ec948073121a3da0f53b8f7a6519d01a609b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Apr 2026 04:30:05 +0000 Subject: [PATCH 32/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 33e3432..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 49aef28..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a623c70a10a34fe0c28a608bb7572f78d9b11e28 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 11 Apr 2026 04:30:29 +0000 Subject: [PATCH 33/45] 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 | 73 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 54 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 66 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4866 insertions(+), 4446 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 147d0cf..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-11T03:40:06.004Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 af668cd..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,54 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( pkg+':size=100', function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..33e3432 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 71248d4..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "utilities", @@ -87,4 +27,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} \ No newline at end of file +} diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..49aef28 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From af08ce187f3999e55f6e9369e342c7710bf50a97 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 14 Apr 2026 10:22:24 +0000 Subject: [PATCH 34/45] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f43d63..a56123c 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/assert-is-array": "^0.2.3", "@stdlib/assert-is-plain-object": "^0.2.3", "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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", From 50ce0d4fbfc4f212e5dd3e3928d45ae04818255b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 14 Apr 2026 10:32:58 +0000 Subject: [PATCH 35/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 33e3432..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 49aef28..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 17b850be238ea654d6d2991bfe50518040676b11 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 14 Apr 2026 10:33:20 +0000 Subject: [PATCH 36/45] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 64 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 43 files changed, 4865 insertions(+), 4480 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 d24de96..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:size=100', pkg ), function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..33e3432 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index a56123c..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^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", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..49aef28 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From 424453850a2e7bb11662b36c2f3feb40fbd7c057 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 May 2026 03:23:01 +0000 Subject: [PATCH 37/45] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8f43d63..a56123c 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/assert-is-array": "^0.2.3", "@stdlib/assert-is-plain-object": "^0.2.3", "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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", From 0d704e0e9040b81ec8e6b4fd4ae453e6d4dc097c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 May 2026 03:23:55 +0000 Subject: [PATCH 38/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 33e3432..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 49aef28..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 210955d34c77e46c16049d1ad41b0d33f371157e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 23 May 2026 03:24:18 +0000 Subject: [PATCH 39/45] 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 | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 64 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4865 insertions(+), 4499 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index e9c3665..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-23T03:21:27.188Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 d24de96..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:size=100', pkg ), function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index e74693f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){return a||i((a={exports:{}}).exports,a),a.exports}};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..33e3432 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index a56123c..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^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", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..49aef28 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From 04b3f632cb9eea7a6b341c8fff4511ec3a1d736e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Jul 2026 03:21:25 +0000 Subject: [PATCH 40/45] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f884233..7ea6124 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/assert-is-array": "^0.2.3", "@stdlib/assert-is-plain-object": "^0.2.3", "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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", From d4783464775b2683113de074e4b3f61605bc3452 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Jul 2026 03:24:18 +0000 Subject: [PATCH 41/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 33e3432..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 49aef28..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 9efda3d9d9e53e4832ab091558c37899f43654fe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Jul 2026 03:24:35 +0000 Subject: [PATCH 42/45] 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 | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 64 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4865 insertions(+), 4499 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 22731f4..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-03T03:19:22.522Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 d24de96..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:size=100', pkg ), function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 30b3455..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){try{return a||i((a={exports:{}}).exports,a),a.exports}catch(u){throw (a=0, u)}};};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..33e3432 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 7ea6124..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^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", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..49aef28 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -}); From 3eca85ab0e5aafb1b0476f6a8e0e3fce82e06d6d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Aug 2026 03:44:05 +0000 Subject: [PATCH 43/45] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f884233..7ea6124 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "@stdlib/assert-is-array": "^0.2.3", "@stdlib/assert-is-plain-object": "^0.2.3", "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^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", From c729a7d66ee23a6e22b7011d9fa384281ed6bf37 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Aug 2026 03:50:25 +0000 Subject: [PATCH 44/45] Remove files --- index.d.ts | 76 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4923 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 b215f4d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,76 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; - -/** -* Property key. -*/ -type PropertyKey = string | number | symbol; - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param arr - input array -* @param fields - list of field names -* @returns output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -declare function nested2views( arr: ArrayLike | AccessorArrayLike>, fields: Collection | AccessorArrayLike ): Array>; - - -// EXPORTS // - -export = nested2views; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 33e3432..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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 49aef28..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2b801900e7a87477a416a2fd76a87013d6368405 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 21 Aug 2026 03:50:43 +0000 Subject: [PATCH 45/45] 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 | 108 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 39 +- SECURITY.md | 5 - benchmark/benchmark.js | 55 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 54 - examples/index.js | 30 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 64 - lib/main.js | 218 - package.json | 64 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 324 -- 44 files changed, 4865 insertions(+), 4500 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 (96%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4a170b0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-21T03:38:22.103Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6ec5b05..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/nested2views) 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 d8b3da8..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/nested2views) 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 2d18d5a..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,112 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '39 15 * * 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 + + ```
@@ -156,7 +147,7 @@ var out = nested2views( x, fields ); ## 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 d24de96..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,55 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var filled2d = require( '@stdlib/array-base-filled2d' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var nested2views = require( './../lib' ); - - -// MAIN // - -bench( format( '%s:size=100', pkg ), function benchmark( b ) { - var fields; - var x; - var i; - var v; - - fields = [ 'x', 'y' ]; - x = filled2d( 10, [ 50, 2 ] ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = nested2views( x, fields ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array' ); - } - } - b.toc(); - if ( !isArray( v ) ) { - b.fail( 'should return an array' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index 732fcfc..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/nested2views" -%% click B href "https://github.com/stdlib-js/array-base-nested2views/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-nested2views/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-nested2views/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-nested2views/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-nested2views/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nested2views -[production-url]: https://github.com/stdlib-js/array-base-nested2views/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-nested2views/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-nested2views/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-nested2views/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-nested2views/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-nested2views/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 3f1a35d..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import nested2views from '../docs/types/index'; -export = nested2views; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 30b3455..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(i,a){return function(){try{return a||i((a={exports:{}}).exports,a),a.exports}catch(u){throw (a=0, u)}};};var l=m(function(E,g){ -var _=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),f=require('@stdlib/utils-define-nonenumerable-property/dist'),C=require('@stdlib/utils-define-read-write-accessor/dist'),O=require('@stdlib/array-base-resolve-getter/dist'),p=require('@stdlib/array-base-accessors/dist'),b=require('@stdlib/array-base-copy/dist');function k(i,a){var u,c,h,v,n,r;if(v=i.length,v<1)return[];if(u=O(i),n=u(i,0).length,n<1)return[];c=b(a);function o(e,t){var s=p(e).accessors;return f(this,"_arr",e),f(this,"_get",s[0]),f(this,"_set",s[1]),_(this,"_i",t),this}for(r=0;r} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = nested2views;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 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* Convert nested arrays to composite views.\n*\n* @module @stdlib/array-base-nested2views\n*\n* @example\n* var nested2views = require( '@stdlib/array-base-nested2views' );\n*\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\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,EAA2B,QAAS,uDAAwD,EAC5FC,EAAmB,QAAS,6CAA8C,EAC1EC,EAAuB,QAAS,0CAA2C,EAC3EC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAY,QAAS,8BAA+B,EACpDC,EAAO,QAAS,yBAA0B,EA8C9C,SAASC,EAAcC,EAAKC,EAAS,CACpC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,GADAF,EAAIL,EAAI,OACHK,EAAI,EACR,MAAO,CAAC,EAIT,GAFAH,EAAON,EAAeI,CAAI,EAC1BM,EAAIJ,EAAMF,EAAK,CAAE,EAAE,OACdM,EAAI,EACR,MAAO,CAAC,EAGTH,EAAOL,EAAMG,CAAO,EAYpB,SAASO,EAAOR,EAAKO,EAAI,CACxB,IAAIE,EAAMZ,EAAWG,CAAI,EAAE,UAC3B,OAAAN,EAAkB,KAAM,OAAQM,CAAI,EACpCN,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzCf,EAAkB,KAAM,OAAQe,EAAK,CAAE,CAAE,EACzChB,EAA0B,KAAM,KAAMc,CAAE,EACjC,IACR,CAGA,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBZ,EAAsBa,EAAM,UAAWL,EAAMI,CAAE,EAAGG,EAAUH,CAAE,EAAGI,EAAUJ,CAAE,CAAE,EAWhF,IAPAd,EAA0Be,EAAM,UAAW,eAAgBI,CAAY,EAGvEnB,EAA0Be,EAAM,UAAW,SAAUK,CAAO,EAG5DT,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAI,KAAM,IAAII,EAAON,EAAMF,EAAKO,CAAE,EAAGA,CAAE,CAAE,EAE1C,OAAOH,EAOP,SAASQ,GAAc,CACtB,IAAIH,EACAK,EAEJA,EAAMZ,EAAMF,EAAK,KAAK,EAAG,EACpBc,IAAQ,KAAK,OACjBL,EAAMZ,EAAWiB,CAAI,EAAE,UACvB,KAAK,KAAOA,EACZ,KAAK,KAAOL,EAAK,CAAE,EACnB,KAAK,KAAOA,EAAK,CAAE,EAErB,CASA,SAASC,EAAUK,EAAM,CACxB,OAAOC,EAQP,SAASA,GAAM,CACd,YAAK,aAAa,EACX,KAAK,KAAM,KAAK,KAAMD,CAAI,CAClC,CACD,CASA,SAASJ,EAAUI,EAAM,CACxB,OAAOE,EAQP,SAASA,EAAKC,EAAQ,CACrB,KAAK,aAAa,EAClB,KAAK,KAAM,KAAK,KAAMH,EAAKG,CAAM,CAClC,CACD,CAQA,SAASL,GAAS,CACjB,IAAIT,EACAe,EACAZ,EAGJ,IADAH,EAAM,CAAC,EACDG,EAAI,EAAGA,EAAID,EAAGC,IACnBY,EAAIhB,EAAMI,CAAE,EACZH,EAAKe,CAAE,EAAI,KAAMA,CAAE,EAEpB,OAAOf,CACR,CACD,CAKAZ,EAAO,QAAUO,IC/JjB,IAAIqB,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "setNonEnumerableReadOnly", "setNonEnumerable", "setReadWriteAccessor", "resolveGetter", "accessors", "copy", "nested2views", "arr", "fields", "oget", "keys", "out", "M", "N", "i", "Datum", "acc", "getValue", "setValue", "updateCache", "toJSON", "ref", "idx", "get", "set", "value", "k", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 26f62b4..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( arr, fields ) - Converts each nested array to a composite view. - - The function assumes that all nested arrays have the same length. - - The number of provided array labels should equal the length of each nested - array. - - Each view in the returned array shares the same memory as the corresponding - elements in the input arrays. Accordingly, mutation of either a nested array - or a view will mutate the other. - - Parameters - ---------- - arr: ArrayLikeObject - Input array containing nested arrays. - - fields: ArrayLikeObject - List of field names. - - Returns - ------- - out: Array - Output array. - - Examples - -------- - > var x = [ [ 1, 2 ], [ 3, 4 ] ]; - > var f = [ 'x', 'y' ]; - > var out = {{alias}}( x, f ); - > var v = out[ 0 ].toJSON() - { 'x': 1, 'y': 2 } - > v = out[ 1 ].toJSON() - { 'x': 3, 'y': 4 } - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 0679a7d..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import nested2views = require( './index' ); - - -// TESTS // - -// The function returns an array of objects... -{ - nested2views( [ [ 1, 2 ] ], [ 'x', 'y' ] ); // $ExpectType Record<"x" | "y", number>[] -} - -// The compiler throws an error if the function is provided a first argument which is not an array-like object... -{ - nested2views( 1, [ 'x', 'y' ] ); // $ExpectError - nested2views( true, [ 'x', 'y' ] ); // $ExpectError - nested2views( false, [ 'x', 'y' ] ); // $ExpectError - nested2views( null, [ 'x', 'y' ] ); // $ExpectError - nested2views( void 0, [ 'x', 'y' ] ); // $ExpectError - nested2views( {}, [ 'x', 'y' ] ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array-like object... -{ - nested2views( [], 1 ); // $ExpectError - nested2views( [], true ); // $ExpectError - nested2views( [], false ); // $ExpectError - nested2views( [], null ); // $ExpectError - nested2views( [], void 0 ); // $ExpectError - nested2views( [], {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - nested2views(); // $ExpectError - nested2views( [] ); // $ExpectError - nested2views( [], [], [] ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index bf4ef78..0000000 --- a/examples/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled2dBy = require( '@stdlib/array-base-filled2d-by' ); -var nested2views = require( './../lib' ); - -var x = filled2dBy( [ 10, 2 ], discreteUniform( -100, 100 ) ); -var fields = [ 'x', 'y' ]; - -var out = nested2views( x, fields ); -console.log( out ); -// => [...] diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 96% rename from docs/types/index.d.ts rename to index.d.ts index 0bc6408..b215f4d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Collection, AccessorArrayLike, ArrayLike } from '@stdlib/types/array'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..33e3432 --- /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-only-property@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-property@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-read-write-accessor@v0.2.3-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-resolve-getter@v0.2.3-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-accessors@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-copy@v0.2.3-esm/index.mjs";function o(o,h){var a,d,p,c,m,u;if((c=o.length)<1)return[];if(a=s(o),(m=a(o,0).length)<1)return[];function f(r,s){var n=i(r).accessors;return e(this,"_arr",r),e(this,"_get",n[0]),e(this,"_set",n[1]),t(this,"_i",s),this}for(d=n(h),u=0;u} arr - input array\n* @param {ArrayLikeObject} fields - list of field names\n* @returns {Array} output array\n*\n* @example\n* var x = [ [ 1, 2 ], [ 3, 4 ] ];\n* var fields = [ 'x', 'y' ];\n*\n* var out = nested2views( x, fields );\n* // returns [ , ]\n*\n* var v0 = out[ 0 ].toJSON();\n* // returns { 'x': 1, 'y': 2 }\n*\n* var v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 4 }\n*\n* // Mutate the first nested array:\n* x[ 0 ][ 0 ] = 5;\n*\n* v0 = out[ 0 ].toJSON();\n* // returns { 'x': 5, 'y': 2 }\n*\n* // Set a view property:\n* out[ 1 ].y = 'beep';\n*\n* v1 = out[ 1 ].toJSON();\n* // returns { 'x': 3, 'y': 'beep' }\n*\n* var y = x.slice();\n* // returns [ [ 5, 2 ], [ 3, 'beep' ] ]\n*/\nfunction nested2views( arr, fields ) {\n\tvar oget;\n\tvar keys;\n\tvar out;\n\tvar M;\n\tvar N;\n\tvar i;\n\n\tM = arr.length;\n\tif ( M < 1 ) {\n\t\treturn [];\n\t}\n\toget = resolveGetter( arr );\n\tN = oget( arr, 0 ).length;\n\tif ( N < 1 ) {\n\t\treturn [];\n\t}\n\t// Create a copy of provided fields to prevent external mutation:\n\tkeys = copy( fields );\n\n\t// eslint-disable-next-line stdlib/jsdoc-typedef-typos\n\t/**\n\t* Constructor for creating a composite view.\n\t*\n\t* @private\n\t* @constructor\n\t* @param {Collection} arr - nested array\n\t* @param {NonNegativeInteger} i - element index\n\t* @returns {Datum} datum instance\n\t*/\n\tfunction Datum( arr, i ) {\n\t\tvar acc = accessors( arr ).accessors;\n\t\tsetNonEnumerable( this, '_arr', arr );\n\t\tsetNonEnumerable( this, '_get', acc[ 0 ] );\n\t\tsetNonEnumerable( this, '_set', acc[ 1 ] );\n\t\tsetNonEnumerableReadOnly( this, '_i', i );\n\t\treturn this;\n\t}\n\n\t// Define accessors for each field...\n\tfor ( i = 0; i < N; i++ ) {\n\t\tsetReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len\n\t}\n\n\t// Define a method for ensuring that cached references are up-to-date:\n\tsetNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache );\n\n\t// Ensure that the returned array correctly serializes to JSON:\n\tsetNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON );\n\n\t// Create a list of composite views...\n\tout = [];\n\tfor ( i = 0; i < M; i++ ) {\n\t\tout.push( new Datum( oget( arr, i ), i ) );\n\t}\n\treturn out;\n\n\t/**\n\t* Updates cached references, if necessary.\n\t*\n\t* @private\n\t*/\n\tfunction updateCache() {\n\t\tvar acc;\n\t\tvar ref;\n\n\t\tref = oget( arr, this._i );\n\t\tif ( ref !== this._arr ) {\n\t\t\tacc = accessors( ref ).accessors;\n\t\t\tthis._arr = ref;\n\t\t\tthis._get = acc[ 0 ];\n\t\t\tthis._set = acc[ 1 ];\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for returning the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction getValue( idx ) {\n\t\treturn get;\n\n\t\t/**\n\t\t* Returns the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @returns {*} result\n\t\t*/\n\t\tfunction get() {\n\t\t\tthis._updateCache();\n\t\t\treturn this._get( this._arr, idx );\n\t\t}\n\t}\n\n\t/**\n\t* Returns an accessor for setting the value associated with a field.\n\t*\n\t* @private\n\t* @param {NonNegativeInteger} idx - field index\n\t* @returns {Function} accessor\n\t*/\n\tfunction setValue( idx ) {\n\t\treturn set;\n\n\t\t/**\n\t\t* Sets the value associated with a field.\n\t\t*\n\t\t* @private\n\t\t* @param {*} value - value to set\n\t\t*/\n\t\tfunction set( value ) {\n\t\t\tthis._updateCache();\n\t\t\tthis._set( this._arr, idx, value );\n\t\t}\n\t}\n\n\t/**\n\t* Serializes a datum to JSON.\n\t*\n\t* @private\n\t* @returns {Object} JSON object\n\t*/\n\tfunction toJSON() {\n\t\tvar out;\n\t\tvar k;\n\t\tvar i;\n\n\t\tout = {};\n\t\tfor ( i = 0; i < N; i++ ) {\n\t\t\tk = keys[ i ];\n\t\t\tout[ k ] = this[ k ];\n\t\t}\n\t\treturn out;\n\t}\n}\n\n\n// EXPORTS //\n\nexport default nested2views;\n"],"names":["nested2views","arr","fields","oget","keys","out","M","N","i","length","resolveGetter","Datum","acc","accessors","setNonEnumerable","this","setNonEnumerableReadOnly","copy","setReadWriteAccessor","prototype","getValue","setValue","ref","_i","_arr","_get","_set","k","push","idx","_updateCache","value"],"mappings":";;8mBA2EA,SAASA,EAAcC,EAAKC,GAC3B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EAGJ,IADAF,EAAIL,EAAIQ,QACC,EACR,MAAO,GAIR,GAFAN,EAAOO,EAAeT,IACtBM,EAAIJ,EAAMF,EAAK,GAAIQ,QACV,EACR,MAAO,GAeR,SAASE,EAAOV,EAAKO,GACpB,IAAII,EAAMC,EAAWZ,GAAMY,UAK3B,OAJAC,EAAkBC,KAAM,OAAQd,GAChCa,EAAkBC,KAAM,OAAQH,EAAK,IACrCE,EAAkBC,KAAM,OAAQH,EAAK,IACrCI,EAA0BD,KAAM,KAAMP,GAC/BO,IACP,CAGD,IAtBAX,EAAOa,EAAMf,GAsBPM,EAAI,EAAGA,EAAID,EAAGC,IACnBU,EAAsBP,EAAMQ,UAAWf,EAAMI,GAAKY,EAAUZ,GAAKa,EAAUb,IAW5E,IAPAQ,EAA0BL,EAAMQ,UAAW,gBAiB3C,WACC,IAAIP,EACAU,GAEJA,EAAMnB,EAAMF,EAAKc,KAAKQ,OACTR,KAAKS,OACjBZ,EAAMC,EAAWS,GAAMT,UACvBE,KAAKS,KAAOF,EACZP,KAAKU,KAAOb,EAAK,GACjBG,KAAKW,KAAOd,EAAK,GAElB,IAzBDI,EAA0BL,EAAMQ,UAAW,UA6E3C,WACC,IAAId,EACAsB,EACAnB,EAGJ,IADAH,EAAM,CAAA,EACAG,EAAI,EAAGA,EAAID,EAAGC,IAEnBH,EADAsB,EAAIvB,EAAMI,IACCO,KAAMY,GAElB,OAAOtB,CACP,IArFDA,EAAM,GACAG,EAAI,EAAGA,EAAIF,EAAGE,IACnBH,EAAIuB,KAAM,IAAIjB,EAAOR,EAAMF,EAAKO,GAAKA,IAEtC,OAAOH,EA2BP,SAASe,EAAUS,GAClB,OAQA,WAEC,OADAd,KAAKe,eACEf,KAAKU,KAAMV,KAAKS,KAAMK,EAC7B,CACD,CASD,SAASR,EAAUQ,GAClB,OAQA,SAAcE,GACbhB,KAAKe,eACLf,KAAKW,KAAMX,KAAKS,KAAMK,EAAKE,EAC3B,CACD,CAoBF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 058b301..0000000 --- a/lib/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert nested arrays to composite views. -* -* @module @stdlib/array-base-nested2views -* -* @example -* var nested2views = require( '@stdlib/array-base-nested2views' ); -* -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ - -// 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 c2cd991..0000000 --- a/lib/main.js +++ /dev/null @@ -1,218 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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-invalid-this */ - -'use strict'; - -// MODULES // - -var setNonEnumerableReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var setNonEnumerable = require( '@stdlib/utils-define-nonenumerable-property' ); -var setReadWriteAccessor = require( '@stdlib/utils-define-read-write-accessor' ); -var resolveGetter = require( '@stdlib/array-base-resolve-getter' ); -var accessors = require( '@stdlib/array-base-accessors' ); -var copy = require( '@stdlib/array-base-copy' ); - - -// MAIN // - -/** -* Converts each nested array to a composite view. -* -* ## Notes -* -* - The function assumes that all nested arrays have the same length. -* - The number of provided array labels should equal the length of each nested array. -* - Each view in the returned array shares the same memory as the corresponding elements in the input arrays. Accordingly, mutation of either a nested array or a view will mutate the other. -* -* @param {Collection} arr - input array -* @param {ArrayLikeObject} fields - list of field names -* @returns {Array} output array -* -* @example -* var x = [ [ 1, 2 ], [ 3, 4 ] ]; -* var fields = [ 'x', 'y' ]; -* -* var out = nested2views( x, fields ); -* // returns [ , ] -* -* var v0 = out[ 0 ].toJSON(); -* // returns { 'x': 1, 'y': 2 } -* -* var v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 4 } -* -* // Mutate the first nested array: -* x[ 0 ][ 0 ] = 5; -* -* v0 = out[ 0 ].toJSON(); -* // returns { 'x': 5, 'y': 2 } -* -* // Set a view property: -* out[ 1 ].y = 'beep'; -* -* v1 = out[ 1 ].toJSON(); -* // returns { 'x': 3, 'y': 'beep' } -* -* var y = x.slice(); -* // returns [ [ 5, 2 ], [ 3, 'beep' ] ] -*/ -function nested2views( arr, fields ) { - var oget; - var keys; - var out; - var M; - var N; - var i; - - M = arr.length; - if ( M < 1 ) { - return []; - } - oget = resolveGetter( arr ); - N = oget( arr, 0 ).length; - if ( N < 1 ) { - return []; - } - // Create a copy of provided fields to prevent external mutation: - keys = copy( fields ); - - // eslint-disable-next-line stdlib/jsdoc-typedef-typos - /** - * Constructor for creating a composite view. - * - * @private - * @constructor - * @param {Collection} arr - nested array - * @param {NonNegativeInteger} i - element index - * @returns {Datum} datum instance - */ - function Datum( arr, i ) { - var acc = accessors( arr ).accessors; - setNonEnumerable( this, '_arr', arr ); - setNonEnumerable( this, '_get', acc[ 0 ] ); - setNonEnumerable( this, '_set', acc[ 1 ] ); - setNonEnumerableReadOnly( this, '_i', i ); - return this; - } - - // Define accessors for each field... - for ( i = 0; i < N; i++ ) { - setReadWriteAccessor( Datum.prototype, keys[ i ], getValue( i ), setValue( i ) ); // eslint-disable-line max-len - } - - // Define a method for ensuring that cached references are up-to-date: - setNonEnumerableReadOnly( Datum.prototype, '_updateCache', updateCache ); - - // Ensure that the returned array correctly serializes to JSON: - setNonEnumerableReadOnly( Datum.prototype, 'toJSON', toJSON ); - - // Create a list of composite views... - out = []; - for ( i = 0; i < M; i++ ) { - out.push( new Datum( oget( arr, i ), i ) ); - } - return out; - - /** - * Updates cached references, if necessary. - * - * @private - */ - function updateCache() { - var acc; - var ref; - - ref = oget( arr, this._i ); - if ( ref !== this._arr ) { - acc = accessors( ref ).accessors; - this._arr = ref; - this._get = acc[ 0 ]; - this._set = acc[ 1 ]; - } - } - - /** - * Returns an accessor for returning the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function getValue( idx ) { - return get; - - /** - * Returns the value associated with a field. - * - * @private - * @returns {*} result - */ - function get() { - this._updateCache(); - return this._get( this._arr, idx ); - } - } - - /** - * Returns an accessor for setting the value associated with a field. - * - * @private - * @param {NonNegativeInteger} idx - field index - * @returns {Function} accessor - */ - function setValue( idx ) { - return set; - - /** - * Sets the value associated with a field. - * - * @private - * @param {*} value - value to set - */ - function set( value ) { - this._updateCache(); - this._set( this._arr, idx, value ); - } - } - - /** - * Serializes a datum to JSON. - * - * @private - * @returns {Object} JSON object - */ - function toJSON() { - var out; - var k; - var i; - - out = {}; - for ( i = 0; i < N; i++ ) { - k = keys[ i ]; - out[ k ] = this[ k ]; - } - return out; - } -} - - -// EXPORTS // - -module.exports = nested2views; diff --git a/package.json b/package.json index 7ea6124..6dd5a0e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Convert nested arrays to composite views.", "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,43 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-accessors": "^0.2.3", - "@stdlib/array-base-copy": "^0.2.3", - "@stdlib/array-base-resolve-getter": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/utils-define-nonenumerable-property": "^0.2.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.3", - "@stdlib/utils-define-read-write-accessor": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-filled2d": "^0.2.4", - "@stdlib/array-base-filled2d-by": "^0.2.3", - "@stdlib/array-base-to-accessor-array": "^0.2.3", - "@stdlib/assert-is-array": "^0.2.3", - "@stdlib/assert-is-plain-object": "^0.2.3", - "@stdlib/random-base-discrete-uniform": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^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", "utilities", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..49aef28 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 1479497..0000000 --- a/test/test.js +++ /dev/null @@ -1,324 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isPlainObject = require( '@stdlib/assert-is-plain-object' ); -var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' ); -var nested2views = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof nested2views, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an empty input array (accessors)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( toAccessorArray( [] ), fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - - fields = [ 'x', 'y' ]; - - actual = nested2views( [ [], [] ], fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an empty array if provided an array of empty arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ toAccessorArray( [] ), toAccessorArray( [] ) ]; - - actual = nested2views( x, fields ); - expected = []; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts nested arrays to objects (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x; - var i; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), toAccessorArray( fields ) ); - for ( i = 0; i < actual.length; i++ ) { - t.strictEqual( isPlainObject( actual[ i ] ), false, 'returns expected value' ); - actual[ i ] = actual[ i ].toJSON(); - } - expected = [ - { - 'x': 1, - 'y': 2 - }, - { - 'x': 3, - 'y': 4 - } - ]; - t.deepEqual( actual, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (indexed)', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns views on the input arrays (accessors)', function test( t ) { - var expected; - var actual; - var fields; - var x1; - var x2; - var xc; - var x; - - fields = [ 'x', 'y' ]; - - x1 = [ 1, 2 ]; - x2 = [ 3, 4 ]; - x = [ x1, x2 ]; - - xc = [ toAccessorArray( x1 ), toAccessorArray( x2 ) ]; - - actual = nested2views( toAccessorArray( xc ), toAccessorArray( fields ) ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - actual[ 0 ].y = -99; - actual[ 1 ].x = 99; - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, -99, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 99, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - expected = [ [ 1, -99 ], [ 99, 4 ] ]; - t.deepEqual( x, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (indexed)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( x, fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports outer array mutation (accessors)', function test( t ) { - var actual; - var fields; - var tmp; - var x; - - fields = [ 'x', 'y' ]; - - x = [ [ 1, 2 ], [ 3, 4 ] ]; - - actual = nested2views( toAccessorArray( x ), fields ); - - t.strictEqual( actual[ 0 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 2, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 4, 'returns expected value' ); - - tmp = x[ 0 ]; - x[ 0 ] = x[ 1 ]; - x[ 1 ] = tmp; - - t.strictEqual( actual[ 0 ].x, 3, 'returns expected value' ); - t.strictEqual( actual[ 0 ].y, 4, 'returns expected value' ); - - t.strictEqual( actual[ 1 ].x, 1, 'returns expected value' ); - t.strictEqual( actual[ 1 ].y, 2, 'returns expected value' ); - - t.end(); -}); - -tape( 'the returned views have a toJSON method which includes all fields', function test( t ) { - var expected; - var actual; - var fields; - var x; - - fields = [ 'a', 'b', 'c', 'd', 'e' ]; - - x = [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ] ]; - - actual = nested2views( x, fields ); - - expected = { - 'a': 1, - 'b': 2, - 'c': 3, - 'd': 4, - 'e': 5 - }; - t.deepEqual( actual[ 0 ].toJSON(), expected, 'returns expected value for first element' ); - - expected = { - 'a': 6, - 'b': 7, - 'c': 8, - 'd': 9, - 'e': 10 - }; - t.deepEqual( actual[ 1 ].toJSON(), expected, 'returns expected value for second element' ); - - t.end(); -});