From b0b65ce442421110e3d8a5afa4514295c8735b1b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 28 Nov 2023 23:08:07 +0000 Subject: [PATCH 01/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 72d3dad..2b3fe66 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.1.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0dba5ea295f840409b6ef2e1c34d67c85187090a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 28 Nov 2023 23:12:22 +0000 Subject: [PATCH 02/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 45 files changed, 6214 insertions(+), 4758 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c2e06eb..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +196,7 @@ console.log( y ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index 9aae1c9..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 0a58b17..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7a7091d..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 2bf74f6..91f984a 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6ddb3de --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 2b3fe66..9ae474e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.1.0", - "@stdlib/array-base-zeros4d": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/math-base-special-abs": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/math-base-special-identity": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-uniform": "^0.1.0", - "@stdlib/utils-nary-function": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..4571a88 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 2831c9b82bdf166e17f395753109cff5eb96f566 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 11:36:45 +0000 Subject: [PATCH 03/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 72d3dad..2b3fe66 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.1.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 13f882396878fda78f99dcdbad0f082d24b92987 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 08:47:14 +0000 Subject: [PATCH 04/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6368 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 91f984a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * var zeros4d = require( `@stdlib/array/base/zeros4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* var zeros4d = require( `@stdlib/array/base/zeros4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6ddb3de..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 4571a88..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ead34e2eed8761f631487f2231336737c6cb52ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 08:49:41 +0000 Subject: [PATCH 05/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 46 files changed, 6214 insertions(+), 4759 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0341107..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T04:47:35.628Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c2e06eb..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +196,7 @@ console.log( y ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/benchmark/benchmark.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index 9aae1c9..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 0a58b17..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7a7091d..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 2bf74f6..91f984a 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6ddb3de --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 2b3fe66..9ae474e 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.1.0", - "@stdlib/array-base-zeros4d": "^0.1.0", - "@stdlib/bench": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/math-base-special-abs": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/math-base-special-identity": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-uniform": "^0.1.0", - "@stdlib/utils-nary-function": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..f1f99fc --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From d1d261f9f853bf30727f84152d9d2feeee0798ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 Dec 2023 02:20:42 +0000 Subject: [PATCH 06/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c01260..b9edd7d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.1.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From bc2e0bbf7c9df571f7dd5c176ad01e08a5175ebd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 Dec 2023 02:23:45 +0000 Subject: [PATCH 07/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6368 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 91f984a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * var zeros4d = require( `@stdlib/array/base/zeros4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* var zeros4d = require( `@stdlib/array/base/zeros4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6ddb3de..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f1f99fc..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 36b617b92aa9029eda23794bd1856988b65251c4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 Dec 2023 02:25:52 +0000 Subject: [PATCH 08/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 46 files changed, 6214 insertions(+), 4764 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 117fac5..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7a7091d..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 2bf74f6..91f984a 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6ddb3de --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index b9edd7d..4fad660 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.1.0", - "@stdlib/array-base-zeros4d": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/math-base-special-abs": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/math-base-special-identity": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-uniform": "^0.1.0", - "@stdlib/utils-nary-function": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..84cb85b --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 546e53344b880fe59e54fdf7f63173989a6a3eae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 Dec 2023 02:26:05 +0000 Subject: [PATCH 09/67] Update README.md for ESM bundle v0.1.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 78a0fdc..4b857e9 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ limitations under the License. ## Usage ```javascript -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.1.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.1.0-esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +160,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.1.0-esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From 5a2ccdc1df70d83c99b38beaeaf0cd68435de3d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 20 Dec 2023 02:26:05 +0000 Subject: [PATCH 10/67] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4b857e9..61816c7 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@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-map4d/tags). For example, + ```javascript import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.1.0-esm/index.mjs'; ``` @@ -54,7 +59,7 @@ import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.1.0 You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.1.0-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +165,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.1.0-esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From 2cb3bf7ecbe8635d68f260d92e9e331e1144aa64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 06:53:23 +0000 Subject: [PATCH 11/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c01260..b9edd7d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.1.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 0cee4372e26de715ad832dd29dca97fc902cefcc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 13:37:11 +0000 Subject: [PATCH 12/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6368 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 91f984a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * var zeros4d = require( `@stdlib/array/base/zeros4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* var zeros4d = require( `@stdlib/array/base/zeros4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6ddb3de..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 84cb85b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4115b97fb49f81d3b44f6b625316071014f2fefe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 13:37:28 +0000 Subject: [PATCH 13/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 47 files changed, 6214 insertions(+), 4765 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 99a793a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T04:13:56.340Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c510c70..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7a7091d..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 2bf74f6..91f984a 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6794254 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index b9edd7d..4fad660 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.1.0", - "@stdlib/array-base-zeros4d": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/math-base-special-abs": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/math-base-special-identity": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-uniform": "^0.1.0", - "@stdlib/utils-nary-function": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..053933c --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 3f756fa39ec5be73fe55b2a802b5663fb102b4a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:11:43 +0000 Subject: [PATCH 14/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c01260..b9edd7d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.1.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d3c0682980a8a3093c02ab996c55176ec4b8dc33 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:28:58 +0000 Subject: [PATCH 15/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6368 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 91f984a..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( `@stdlib/array/base/ones4d` ); - * var zeros4d = require( `@stdlib/array/base/zeros4d` ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( `@stdlib/array/base/ones4d` ); -* var zeros4d = require( `@stdlib/array/base/zeros4d` ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6794254..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 053933c..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From a5ca1ed2a60efa47c0ae487fe21c648fb3317e9a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 7 Jan 2024 22:29:16 +0000 Subject: [PATCH 16/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 57 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 46 files changed, 6214 insertions(+), 4764 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c510c70..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -197,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 7a7091d..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6794254 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index b9edd7d..4fad660 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.1.0", - "@stdlib/array-base-zeros4d": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/math-base-special-abs": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/math-base-special-identity": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-uniform": "^0.1.0", - "@stdlib/utils-nary-function": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..740b14a --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 3afef302ad5acf10e4e9ce24b4e6c18cb8994e71 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 07:23:13 +0000 Subject: [PATCH 17/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3c01260..b9edd7d 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.1.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From d7b8c55621e3746abbd87c774a4d4cd8370f1e62 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 12:53:19 +0000 Subject: [PATCH 18/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6368 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6794254..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 740b14a..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 4fa35cc6683b267bb530352ebc0087c0b72eb723 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Feb 2024 12:53:40 +0000 Subject: [PATCH 19/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 47 files changed, 6214 insertions(+), 4770 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index ef2ca1e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-02-01T05:03:04.553Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index c510c70..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6794254 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index b9edd7d..4fad660 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.2.0", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.1", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.1.0", - "@stdlib/array-base-zeros4d": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/math-base-special-abs": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/math-base-special-identity": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-uniform": "^0.1.0", - "@stdlib/utils-nary-function": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..f8acbb9 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 97354533fbe1715482f7c76fdf9bfc013409ac50 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 14:07:58 +0000 Subject: [PATCH 20/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4beca69..3beb1b6 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.1.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 5c88ec23a226506050a0df76d8c4191947b670fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:00:54 +0000 Subject: [PATCH 21/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6368 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6794254..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f8acbb9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 897379b3318b82c36fa50e9eed3d0b9ab8e2d678 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 21:01:54 +0000 Subject: [PATCH 22/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 46 files changed, 6214 insertions(+), 4773 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 e2645cb..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6794254 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 3beb1b6..cbcf999 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.1.0", - "@stdlib/array-base-zeros4d": "^0.1.0", - "@stdlib/math-base-assert-is-nan": "^0.1.1", - "@stdlib/math-base-special-abs": "^0.1.1", - "@stdlib/math-base-special-floor": "^0.1.1", - "@stdlib/math-base-special-identity": "^0.1.1", - "@stdlib/math-base-special-pow": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "@stdlib/random-base-uniform": "^0.1.0", - "@stdlib/utils-nary-function": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..df1a244 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 49810b12f45405e4109eddbdc1f4d621aff038b0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 22:09:39 +0000 Subject: [PATCH 23/67] Update README.md for ESM bundle v0.2.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 908d17a..1278bc0 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ limitations under the License. ## Usage ```javascript -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.0-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.0-esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +160,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.0-esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From 41d71b131467349718efad180c00bf1b5c1be181 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 14 Feb 2024 22:09:40 +0000 Subject: [PATCH 24/67] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1278bc0..7d1e0c6 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@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-map4d/tags). For example, + ```javascript import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.0-esm/index.mjs'; ``` @@ -54,7 +59,7 @@ import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.0 You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.0-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +165,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.0-esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From ceca4bfd7b60b110b175b2091576cd0ba126dc1b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 00:17:32 +0000 Subject: [PATCH 25/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0a1675b..dec8927 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.0", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From a6b25cdecd50fa165265b1084cc864a8ebacee06 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 05:43:52 +0000 Subject: [PATCH 26/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6368 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6794254..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.1.0-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index df1a244..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 652f50ff13ecc3e14809e74669e680b8c5c3ec60 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 05:45:21 +0000 Subject: [PATCH 27/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 46 files changed, 4879 insertions(+), 4767 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index dec8927..a49253b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.0", - "@stdlib/array-base-zeros4d": "^0.2.0", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/math-base-special-abs": "^0.2.0", - "@stdlib/math-base-special-floor": "^0.2.1", - "@stdlib/math-base-special-identity": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.0", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.0", - "@stdlib/random-base-uniform": "^0.2.0", - "@stdlib/utils-nary-function": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 96850791c649da66d9d47f77cba559928c40ea11 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 07:25:38 +0000 Subject: [PATCH 28/67] Update README.md for ESM bundle v0.2.1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fcf3d1f..04e6f9b 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ limitations under the License. ## Usage ```javascript -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.1-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.1-esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +160,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.1-esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From fbdecb09f7f36592cb8e1b57a7d3d8ffb6e35bb3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 07:25:39 +0000 Subject: [PATCH 29/67] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 04e6f9b..5841218 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@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-map4d/tags). For example, + ```javascript import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.1-esm/index.mjs'; ``` @@ -54,7 +59,7 @@ import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.1 You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.1-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +165,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.1-esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From 2728a5c25a1782527aea1d70b296e956079d3933 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 06:45:45 +0000 Subject: [PATCH 30/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e438f5b..3057e65 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.1", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7efcfa4f79265aecd42187ea3e363f136fbaa6f1 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 12:09:15 +0000 Subject: [PATCH 31/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2956dabd8131074173ae7d2a3de783777464b5bf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 12:09:40 +0000 Subject: [PATCH 32/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 47 files changed, 4879 insertions(+), 4769 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6d63c3a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T04:49:57.327Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 3057e65..a49253b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.1", - "@stdlib/array-base-zeros4d": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/math-base-special-abs": "^0.2.1", - "@stdlib/math-base-special-floor": "^0.2.1", - "@stdlib/math-base-special-identity": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 93aaf62ed32f4ec76c408cf419e7816599d9a733 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 06:02:31 +0000 Subject: [PATCH 33/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 88ffcaf..c9d69db 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.1", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 037c4f8aec9bc1e521115f1168998a0ca492ad2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 11:14:46 +0000 Subject: [PATCH 34/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c615e26d83f9662857f2a30ae2d114d6c8136bbb Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 11:15:04 +0000 Subject: [PATCH 35/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 47 files changed, 4879 insertions(+), 4772 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 52ffd40..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T04:05:20.619Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index c9d69db..a49253b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.1", - "@stdlib/array-base-zeros4d": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/math-base-special-abs": "^0.2.1", - "@stdlib/math-base-special-floor": "^0.2.2", - "@stdlib/math-base-special-identity": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From c4c809f2c15d57a240fee1a3472358802335d58e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 02:25:17 +0000 Subject: [PATCH 36/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 88ffcaf..c9d69db 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.1", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From c7e800925e7a820ffb5a1a10a0749c2e3001826d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 07:53:45 +0000 Subject: [PATCH 37/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c49a2c31b93eaa60dcca7ae1580477c86a14c0ba Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 07:54:04 +0000 Subject: [PATCH 38/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 46 files changed, 4879 insertions(+), 4773 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index c9d69db..a49253b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.1", - "@stdlib/array-base-zeros4d": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.1", - "@stdlib/math-base-special-abs": "^0.2.1", - "@stdlib/math-base-special-floor": "^0.2.2", - "@stdlib/math-base-special-identity": "^0.2.1", - "@stdlib/math-base-special-pow": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 5a33c7f2a06d6079345840ba702f859b130300e4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:19:39 +0000 Subject: [PATCH 39/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a311552..4e029f2 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.1", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From b96712dc94812637f68d4fe2e6b1926cf4a1ba1c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:36:00 +0000 Subject: [PATCH 40/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 699d3c5ac89d5c8ffde4f75c04ab7eb58588de6c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:36:16 +0000 Subject: [PATCH 41/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 102 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 46 files changed, 4879 insertions(+), 4881 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 4e029f2..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.1", - "@stdlib/array-base-zeros4d": "^0.2.1", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 77e925f9d225f7e38ffa0cf6936f28c82e2e9b05 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:44:39 +0000 Subject: [PATCH 42/67] Update README.md for ESM bundle v0.2.2 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a9b81fa..40c813e 100644 --- a/README.md +++ b/README.md @@ -48,13 +48,13 @@ limitations under the License. ## Usage ```javascript -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.2-esm/index.mjs'; ``` You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.2-esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +160,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.2-esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From d1a57187b7dd3697aa75bac992104f0e9a1f2c2a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 28 Jul 2024 21:44:40 +0000 Subject: [PATCH 43/67] Auto-generated commit --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 40c813e..a5c3da3 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ limitations under the License. ## Usage +```javascript +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@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-map4d/tags). For example, + ```javascript import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.2-esm/index.mjs'; ``` @@ -54,7 +59,7 @@ import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.2 You can also import the following named exports from the package: ```javascript -import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.2-esm/index.mjs'; +import { assign } from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; ``` #### map4d( x, shape, fcn\[, thisArg] ) @@ -160,7 +165,7 @@ var discreteUniform = require( 'https://cdn.jsdelivr.net/gh/stdlib-js/random-bas import filled4dBy from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-filled4d-by@esm/index.mjs'; import naryFunction from 'https://cdn.jsdelivr.net/gh/stdlib-js/utils-nary-function@esm/index.mjs'; import abs from 'https://cdn.jsdelivr.net/gh/stdlib-js/math-base-special-abs@esm/index.mjs'; -import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@v0.2.2-esm/index.mjs'; +import map4d from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-map4d@esm/index.mjs'; var shape = [ 1, 3, 3, 3 ]; From 0d393b5cbd1a66ddbd366d8211e0226f4eacec9d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 06:52:47 +0000 Subject: [PATCH 44/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 925cfc2..1f91428 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7353bc69cb62d03f3e92cb7b248fa06dea620459 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 11:33:03 +0000 Subject: [PATCH 45/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c2268154d8d90302ce9b3a797d763e1428898998 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 1 Aug 2024 11:33:17 +0000 Subject: [PATCH 46/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 78 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 47 files changed, 4879 insertions(+), 4860 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 1702c11..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-01T04:56:22.569Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 1f91428..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 57d7ea8b7f572afb457a08b132071ef8cd5e323f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 3 Aug 2024 22:03:40 +0000 Subject: [PATCH 47/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 925cfc2..1f91428 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 3f2c188a05255f0bf1ca3e93afef669b0562996f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 4 Aug 2024 01:18:05 +0000 Subject: [PATCH 48/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From e0be2079797dddcd519d29a2c5f948ff73d8cc75 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 4 Aug 2024 01:18:23 +0000 Subject: [PATCH 49/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 102 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 47 files changed, 4879 insertions(+), 4884 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d2f783a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-08-03T20:24:22.983Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 1f91428..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.3.2", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 3315631e85d9853408380e0f9536dd9a38012cc6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 07:11:23 +0000 Subject: [PATCH 50/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 19c86b6..096bf47 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 6bf7f9424f0af98bb919598afae92c4d60a242a2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 11:28:38 +0000 Subject: [PATCH 51/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1c9176fba6e32a63f6594e3fddf23235ef67de2c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Sep 2024 11:28:54 +0000 Subject: [PATCH 52/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 102 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 47 files changed, 4879 insertions(+), 4884 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 350e476..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-09-01T05:16:21.149Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 096bf47..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 93e24b59d9c4b68e007ed0c83eea762514aeabde Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 07:27:18 +0000 Subject: [PATCH 53/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 19c86b6..096bf47 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 4a2119258afb47a1edd1982850580237fea68d7d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 12:05:50 +0000 Subject: [PATCH 54/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 801df14bc4f8a577a6ce05e46a64252d3794f834 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 1 Oct 2024 12:06:07 +0000 Subject: [PATCH 55/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 102 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 47 files changed, 4879 insertions(+), 4884 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 751418e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-10-01T05:28:05.698Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 096bf47..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 0802678af733a6814d3f1e79fcea3a5f606fd7b6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 07:19:38 +0000 Subject: [PATCH 56/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 19c86b6..096bf47 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 15893b8d3ce5cd0badee900e3f0445c7805afc35 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 11:18:12 +0000 Subject: [PATCH 57/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From f45c6f1a8320f22f45895eaaba673944a36cc366 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Nov 2024 11:18:25 +0000 Subject: [PATCH 58/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 ---- .github/workflows/publish.yml | 252 -- .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 102 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 -- test/test.js | 38 - test/test.main.js | 258 -- 47 files changed, 4879 insertions(+), 4884 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 2098922..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-11-01T05:32:00.625Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 096bf47..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.4.1", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 7f6a579ae75a40768371ad23f71f4fd91bb705a8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 07:35:30 +0000 Subject: [PATCH 59/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a1c37ec..45e9ac0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 7434a1dd8f97d05cf8dd262fe9354f1ffdb12de4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 11:29:09 +0000 Subject: [PATCH 60/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From b762f36db9caf384aed5b94adc271c7ce5d9ed17 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Dec 2024 11:29:26 +0000 Subject: [PATCH 61/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 102 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 48 files changed, 4879 insertions(+), 4989 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.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 305910e..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-01T05:40:32.099Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 45e9ac0..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From 6fb17d801206d06e16bc744e32eb5d64fd9d3de8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 03:29:59 +0000 Subject: [PATCH 62/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a1c37ec..45e9ac0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 1f2ba7d99044c40a8d710b46b6038dedbb48c0fc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:44:30 +0000 Subject: [PATCH 63/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 7ed8ce478b0b3cd52f7ba9ceb18c9316e3af2f31 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Dec 2024 04:44:45 +0000 Subject: [PATCH 64/67] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 102 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 48 files changed, 4879 insertions(+), 4989 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.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 495df13..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-12-30T02:58:43.823Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index b8b89af..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/map4d) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index a0c6ce4..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 181ee35..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/math-base-special-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..43e60b8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 45e9ac0..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-identity": "^0.2.2", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); From b768827f48aaf385d4cffcc9fafd6c9d37bc97c6 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:31:34 +0000 Subject: [PATCH 65/67] Transform error messages --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ff57ab8..15799ee 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,8 @@ }, "dependencies": { "@stdlib/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2" + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, "devDependencies": { "@stdlib/array-base-filled4d-by": "^0.2.2", @@ -90,4 +91,4 @@ "type": "opencollective", "url": "https://opencollective.com/stdlib" } -} +} \ No newline at end of file From 20d3e6bfa6ef8172ce876d0dfa3e33499786811a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:43:56 +0000 Subject: [PATCH 66/67] Remove files --- index.d.ts | 186 -- index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 5033 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 4cbeb34..0000000 --- a/index.d.ts +++ /dev/null @@ -1,186 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 { Array4D } from '@stdlib/types/array'; -import { Shape4D } from '@stdlib/types/ndarray'; - -/** -* Array element indices. -*/ -type Indices = [ number, number, number, number ]; - -/** -* Callback invoked for each array element. -* -* @returns result -*/ -type Nullary = ( this: V ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @returns result -*/ -type Unary = ( this: V, value: T ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @returns result -*/ -type Binary = ( this: V, value: T, indices: Indices ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Ternary = ( this: V, value: T, indices: Indices, array: Array4D ) => U; - -/** -* Callback invoked for each array element. -* -* @param value - array element -* @param indices - current array element indices -* @param array - input array -* @returns result -*/ -type Callback = Nullary | Unary | Binary | Ternary; - -/** -* Interface describing the main export. -*/ -interface Routine { - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. - * - * @param x - input nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = map4d( x, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - */ - ( x: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; - - /** - * Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. - * - * @param x - input nested array - * @param y - output nested array - * @param shape - array shape - * @param fcn - function to apply - * @param thisArg - function execution context - * - * @example - * var ones4d = require( '@stdlib/array-base-ones4d' ); - * var zeros4d = require( '@stdlib/array-base-zeros4d' ); - * - * function scale( x ) { - * return x * 10.0; - * } - * - * var shape = [ 1, 1, 2, 2 ]; - * - * var x = ones4d( shape ); - * var y = zeros4d( shape ); - * - * var out = map4d.assign( x, y, shape, scale ); - * // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] - * - * var bool = ( out === y ); - * // returns true - */ - assign( x: Array4D, y: Array4D, shape: Shape4D, fcn: Callback, thisArg?: ThisParameterType> ): Array4D; -} - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* ## Notes -* -* - The applied function is provided the following arguments: -* -* - **value**: array element. -* - **indices**: current array element indices. -* -- **array**: input nested array. -* -* @param x - input nested array -* @param shape - array shape -* @param fcn - function to apply -* @param thisArg - function execution context -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -declare var map4d: Routine; - - -// EXPORTS // - -export = map4d; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 43e60b8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 376e063..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2f80fbf054c6c64bf7c99de54deea4928867362d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 26 May 2025 01:44:25 +0000 Subject: [PATCH 67/67] 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 | 136 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 59 +- SECURITY.md | 5 - benchmark/benchmark.assign.js | 120 - benchmark/benchmark.js | 114 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 7 - dist/index.js.map | 7 - docs/repl.txt | 71 - docs/types/test.ts | 227 - examples/index.js | 33 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/assign.js | 100 - lib/index.js | 75 - lib/main.js | 91 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.assign.js | 272 - test/test.js | 38 - test/test.main.js | 258 - 48 files changed, 4879 insertions(+), 5026 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.assign.js 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 (98%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/assign.js delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.assign.js delete mode 100644 test/test.js delete mode 100644 test/test.main.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 7063e82..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-05-26T01:26:50.109Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index e013bb2..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/map4d) 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 dc1023b..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/map4d) 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 7c8261c..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: '31 7 * * 1' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 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 + + ```
@@ -199,7 +196,7 @@ console.log( y ); ## 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.assign.js b/benchmark/benchmark.assign.js deleted file mode 100644 index 84f51b6..0000000 --- a/benchmark/benchmark.assign.js +++ /dev/null @@ -1,120 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/number-float64-base-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ).assign; - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x; - var y; - - x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - y = zeros4d( shape ); - - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, y, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:assign:size='+numel( sh ), f ); - } -} - -main(); diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index cfff9ef..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,114 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 uniform = require( '@stdlib/random-base-uniform' ).factory; -var isnan = require( '@stdlib/math-base-assert-is-nan' ); -var pow = require( '@stdlib/math-base-special-pow' ); -var floor = require( '@stdlib/math-base-special-floor' ); -var identity = require( '@stdlib/number-float64-base-identity' ); -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var pkg = require( './../package.json' ).name; -var map4d = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Creates a benchmark function. -* -* @private -* @param {PositiveIntegerArray} shape - array shape -* @returns {Function} benchmark function -*/ -function createBenchmark( shape ) { - var x = filled4dBy( shape, uniform( -100.0, 100.0 ) ); - return benchmark; - - /** - * Benchmark function. - * - * @private - * @param {Benchmark} b - benchmark instance - */ - function benchmark( b ) { - var out; - var i0; - var i1; - var i2; - var i3; - var i; - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = map4d( x, shape, identity ); - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - } - b.toc(); - - i3 = i % shape[ 0 ]; - i2 = i % shape[ 1 ]; - i1 = i % shape[ 2 ]; - i0 = i % shape[ 3 ]; - if ( isnan( out[ i3 ][ i2 ][ i1 ][ i0 ] ) ) { - b.fail( 'should not return NaN' ); - } - b.pass( 'benchmark finished' ); - b.end(); - } -} - - -// MAIN // - -/** -* Main execution sequence. -* -* @private -*/ -function main() { - var min; - var max; - var sh; - var N; - var f; - var i; - - min = 1; // 10^min - max = 6; // 10^max - - for ( i = min; i <= max; i++ ) { - N = floor( pow( pow( 10, i ), 1.0/4.0 ) ); - sh = [ N, N, N, N ]; - f = createBenchmark( sh ); - bench( pkg+'::equidimensional:size='+numel( sh ), f ); - } -} - -main(); diff --git a/branches.md b/branches.md deleted file mode 100644 index 8d49814..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/map4d" -%% click B href "https://github.com/stdlib-js/array-base-map4d/tree/main" -%% click C href "https://github.com/stdlib-js/array-base-map4d/tree/production" -%% click D href "https://github.com/stdlib-js/array-base-map4d/tree/esm" -%% click E href "https://github.com/stdlib-js/array-base-map4d/tree/deno" -%% click F href "https://github.com/stdlib-js/array-base-map4d/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/map4d -[production-url]: https://github.com/stdlib-js/array-base-map4d/tree/production -[deno-url]: https://github.com/stdlib-js/array-base-map4d/tree/deno -[deno-readme]: https://github.com/stdlib-js/array-base-map4d/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/array-base-map4d/tree/umd -[umd-readme]: https://github.com/stdlib-js/array-base-map4d/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/array-base-map4d/tree/esm -[esm-readme]: https://github.com/stdlib-js/array-base-map4d/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 d08e4f5..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import map4d from '../docs/types/index'; -export = map4d; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index bf2c6f0..0000000 --- a/dist/index.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict";var q=function(o,r){return function(){return r||o((r={exports:{}}).exports,r),r.exports}};var O=q(function(C,g){ -function k(o,r,s,p){var m,e,f,n,t,a,v,i,u,S,l,c,d,x,y;for(m=r[3],e=r[2],f=r[1],n=r[0],y=[],i=0;i} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = map4d;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* var ones4d = require( '@stdlib/array-base-ones4d' );\n* var zeros4d = require( '@stdlib/array-base-zeros4d' );\n* var map4d = require( '@stdlib/array-base-map4d' );\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cA4CA,SAASC,EAAOC,EAAGC,EAAOC,EAAKC,EAAU,CACxC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,EAOJ,IALAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACd,EAAI,CAAC,EACCU,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,CAAG,EACXM,EAAK,CAAC,EACAP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAK,CAAC,EACAN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAK,CAAC,EACAL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAG,KAAMX,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGR,CAAE,CAAE,EAE/De,EAAG,KAAMF,CAAG,CACb,CACAI,EAAG,KAAMF,CAAG,CACb,CACA,EAAE,KAAME,CAAG,CACZ,CACA,OAAO,CACR,CAKAnB,EAAO,QAAUC,IC1FjB,IAAAmB,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAuDA,SAASC,EAAOC,EAAGC,EAAGC,EAAOC,EAAKC,EAAU,CAC3C,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,CAAE,EACdI,EAAKJ,EAAO,CAAE,EACdK,EAAKL,EAAO,CAAE,EACdM,EAAKN,EAAO,CAAE,EACTG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOP,EAER,IAAMW,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKjB,EAAGY,CAAG,EACXM,EAAKjB,EAAGW,CAAG,EACLD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,CAAG,EACZK,EAAKE,EAAIP,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,CAAG,EACZI,EAAKE,EAAIN,CAAG,EACND,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,CAAG,EAAIN,EAAI,KAAMC,EAASS,EAAIJ,CAAG,EAAG,CAAEG,EAAID,EAAID,EAAID,CAAG,EAAGT,CAAE,EAKlE,OAAOC,CACR,CAKAH,EAAO,QAAUC,ICrCjB,IAAIoB,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD", - "names": ["require_main", "__commonJSMin", "exports", "module", "map4d", "x", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "require_assign", "__commonJSMin", "exports", "module", "map4d", "x", "y", "shape", "fcn", "thisArg", "S0", "S1", "S2", "S3", "i0", "i1", "i2", "i3", "x0", "y0", "x1", "y1", "x2", "y2", "setReadOnly", "main", "assign"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 9f8d2b2..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,71 +0,0 @@ - -{{alias}}( x, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a new four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: Array - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var y = {{alias}}( x, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - - -{{alias}}.assign( x, y, shape, fcn[, thisArg] ) - Applies a function to elements in a four-dimensional nested input array and - assigns results to elements in a four-dimensional nested output array. - - Parameters - ---------- - x: ArrayLikeObject - Input nested array. - - y: ArrayLikeObject - Output nested array. - - shape: Array - Array shape. - - fcn: Function - Function to apply. - - thisArg: any (optional) - Function execution context. - - Returns - ------- - out: ArrayLikeObject - Output nested array. - - Examples - -------- - > var x = [ [ [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ] ]; - > var y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - > var shape = [ 1, 1, 2, 2 ]; - > var out = {{alias}}.assign( x, y, shape, {{alias:@stdlib/math/base/special/abs}} ) - [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ] - > var b = ( out === y ) - true - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 93454e9..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,227 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 map4d = require( './index' ); - -/** -* Unary function. -* -* @param value - input value -* @returns result -*/ -function fcn( value: number ): number { - return value; -} - - -// TESTS // - -// The function returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d( x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the function is provided a first argument which is not a nested array... -{ - map4d( 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d( 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d( ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, 'abc', fcn ); // $ExpectError - map4d( x, 3.14, fcn ); // $ExpectError - map4d( x, true, fcn ); // $ExpectError - map4d( x, false, fcn ); // $ExpectError - map4d( x, null, fcn ); // $ExpectError - map4d( x, [ '1' ], fcn ); // $ExpectError - map4d( x, {}, fcn ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn ); // $ExpectError - - map4d( x, 'abc', fcn, {} ); // $ExpectError - map4d( x, 3.14, fcn, {} ); // $ExpectError - map4d( x, true, fcn, {} ); // $ExpectError - map4d( x, false, fcn, {} ); // $ExpectError - map4d( x, null, fcn, {} ); // $ExpectError - map4d( x, [ '1' ], fcn, {} ); // $ExpectError - map4d( x, {}, fcn, {} ); // $ExpectError - map4d( x, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d( x, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d( x, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d(); // $ExpectError - map4d( x ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d( x, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} - -// Attached to the main export is an `assign` method which returns a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectType Array4D - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectType Array4D -} - -// The compiler throws an error if the `assign` method is provided a first argument which is not a nested array... -{ - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( 'abc', y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( 3.14, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( true, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( false, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( null, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( [ '1' ], y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( {}, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( ( x: number ): number => x, y, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a second argument which is not a nested array... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn ); // $ExpectError - - map4d.assign( x, 'abc', [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, 3.14, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, true, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, false, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, null, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, [ '1' ], [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, {}, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError - map4d.assign( x, ( x: number ): number => x, [ 1, 1, 2, 2 ], fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a third argument which is not an array of numbers... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, 'abc', fcn ); // $ExpectError - map4d.assign( x, y, 3.14, fcn ); // $ExpectError - map4d.assign( x, y, true, fcn ); // $ExpectError - map4d.assign( x, y, false, fcn ); // $ExpectError - map4d.assign( x, y, null, fcn ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn ); // $ExpectError - map4d.assign( x, y, {}, fcn ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn ); // $ExpectError - - map4d.assign( x, y, 'abc', fcn, {} ); // $ExpectError - map4d.assign( x, y, 3.14, fcn, {} ); // $ExpectError - map4d.assign( x, y, true, fcn, {} ); // $ExpectError - map4d.assign( x, y, false, fcn, {} ); // $ExpectError - map4d.assign( x, y, null, fcn, {} ); // $ExpectError - map4d.assign( x, y, [ '1' ], fcn, {} ); // $ExpectError - map4d.assign( x, y, {}, fcn, {} ); // $ExpectError - map4d.assign( x, y, ( x: number ): number => x, fcn, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided a fourth argument which is not a valid callback... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc' ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14 ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {} ); // $ExpectError - - map4d.assign( x, y, [ 1, 1, 2, 2 ], 'abc', {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], 3.14, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], true, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], false, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], null, {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], [ '1' ], {} ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], {}, {} ); // $ExpectError -} - -// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... -{ - const x = [ [ [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ] ] ]; - const y = [ [ [ [ 0.0, 0.0 ], [ 0.0, 0.0 ] ] ] ]; - - map4d.assign(); // $ExpectError - map4d.assign( x, y ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ] ); // $ExpectError - map4d.assign( x, y, [ 1, 1, 2, 2 ], fcn, {}, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index 150f65d..0000000 --- a/examples/index.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'; - -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ).factory; -var filled4dBy = require( '@stdlib/array-base-filled4d-by' ); -var naryFunction = require( '@stdlib/utils-nary-function' ); -var abs = require( '@stdlib/math-base-special-abs' ); -var map4d = require( './../lib' ); - -var shape = [ 1, 3, 3, 3 ]; - -var x = filled4dBy( shape, discreteUniform( -100, 100 ) ); -console.log( x ); - -var y = map4d( x, shape, naryFunction( abs, 1 ) ); -console.log( y ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 98% rename from docs/types/index.d.ts rename to index.d.ts index 5275fae..4cbeb34 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { Array4D } from '@stdlib/types/array'; import { Shape4D } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..f12aa27 --- /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 r from"https://cdn.jsdelivr.net/gh/stdlib-js/utils-define-nonenumerable-read-only-property@v0.2.1-esm/index.mjs";function n(r,n,s,e){var o,f,t,u,a,i,l,p,d,h,c,m,v,g,j;for(o=n[3],f=n[2],t=n[1],u=n[0],j=[],p=0;p} x - input nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*/\nfunction map4d( x, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\tvar y;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\ty = [];\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = [];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = [];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = [];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t\ty1.push( y0 );\n\t\t\t}\n\t\t\ty2.push( y1 );\n\t\t}\n\t\ty.push( y2 );\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MAIN //\n\n/**\n* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array.\n*\n* ## Notes\n*\n* - The function assumes that the input and output arrays have the same shape.\n*\n* @param {ArrayLikeObject} x - input nested array\n* @param {ArrayLikeObject} y - output nested array\n* @param {NonNegativeIntegerArray} shape - array shape\n* @param {Function} fcn - function to apply\n* @param {*} [thisArg] - function execution context\n* @returns {Array} output array\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\nfunction map4d( x, y, shape, fcn, thisArg ) {\n\tvar S0;\n\tvar S1;\n\tvar S2;\n\tvar S3;\n\tvar i0;\n\tvar i1;\n\tvar i2;\n\tvar i3;\n\tvar x0;\n\tvar y0;\n\tvar x1;\n\tvar y1;\n\tvar x2;\n\tvar y2;\n\n\tS0 = shape[ 3 ];\n\tS1 = shape[ 2 ];\n\tS2 = shape[ 1 ];\n\tS3 = shape[ 0 ];\n\tif ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) {\n\t\treturn y;\n\t}\n\tfor ( i3 = 0; i3 < S3; i3++ ) {\n\t\tx2 = x[ i3 ];\n\t\ty2 = y[ i3 ];\n\t\tfor ( i2 = 0; i2 < S2; i2++ ) {\n\t\t\tx1 = x2[ i2 ];\n\t\t\ty1 = y2[ i2 ];\n\t\t\tfor ( i1 = 0; i1 < S1; i1++ ) {\n\t\t\t\tx0 = x1[ i1 ];\n\t\t\t\ty0 = y1[ i1 ];\n\t\t\t\tfor ( i0 = 0; i0 < S0; i0++ ) {\n\t\t\t\t\ty0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\treturn y;\n}\n\n\n// EXPORTS //\n\nexport default map4d;\n","/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.\n*\n* @module @stdlib/array-base-map4d\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = map4d( x, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* @example\n* import ones4d from '@stdlib/array-base-ones4d';\n* import zeros4d from '@stdlib/array-base-zeros4d';\n* import map4d from '@stdlib/array-base-map4d';\n*\n* function scale( x ) {\n* return x * 10.0;\n* }\n*\n* var shape = [ 1, 1, 2, 2 ];\n*\n* var x = ones4d( shape );\n* var y = zeros4d( shape );\n*\n* var out = map4d.assign( x, y, shape, scale );\n* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ]\n*\n* var bool = ( out === y );\n* // returns true\n*/\n\n// MODULES //\n\nimport setReadOnly from '@stdlib/utils-define-nonenumerable-read-only-property';\nimport main from './main.js';\nimport assign from './assign.js';\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nexport default main;\n"],"names":["map4d","x","shape","fcn","thisArg","S0","S1","S2","S3","i0","i1","i2","i3","x0","y0","x1","y1","x2","y2","y","push","call","setReadOnly","main","assign"],"mappings":";;wHA4CA,SAASA,EAAOC,EAAGC,EAAOC,EAAKC,GAC9B,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAOJ,IALAd,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACZiB,EAAI,GACEP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAK,EAAKhB,EAAGW,GACRM,EAAK,GACCP,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAI,EAAKE,EAAIN,GACTK,EAAK,GACCN,EAAK,EAAGA,EAAKJ,EAAII,IAAO,CAG7B,IAFAG,EAAKE,EAAIL,GACTI,EAAK,GACCL,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAGM,KAAMjB,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,IAE3De,EAAGI,KAAMN,EACT,CACDI,EAAGE,KAAMJ,EACT,CACDG,EAAEC,KAAMF,EACR,CACD,OAAOC,CACR,CC9BA,SAASnB,EAAOC,EAAGkB,EAAGjB,EAAOC,EAAKC,GACjC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAMJ,GAJAb,EAAKH,EAAO,GACZI,EAAKJ,EAAO,GACZK,EAAKL,EAAO,GACZM,EAAKN,EAAO,GACPG,GAAM,GAAKC,GAAM,GAAKC,GAAM,GAAKC,GAAM,EAC3C,OAAOW,EAER,IAAMP,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAK,EAAKhB,EAAGW,GACRM,EAAKC,EAAGP,GACFD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAI,EAAKE,EAAIN,GACTK,EAAKE,EAAIP,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IAGtB,IAFAG,EAAKE,EAAIL,GACTI,EAAKE,EAAIN,GACHD,EAAK,EAAGA,EAAKJ,EAAII,IACtBK,EAAIL,GAAON,EAAIkB,KAAMjB,EAASS,EAAIJ,GAAM,CAAEG,EAAID,EAAID,EAAID,GAAMR,GAKhE,OAAOkB,CACR,CCzBAG,EAAAC,EAAA,SAAAC"} \ No newline at end of file diff --git a/lib/assign.js b/lib/assign.js deleted file mode 100644 index 9cc441a..0000000 --- a/lib/assign.js +++ /dev/null @@ -1,100 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a four-dimensional nested output array. -* -* ## Notes -* -* - The function assumes that the input and output arrays have the same shape. -* -* @param {ArrayLikeObject} x - input nested array -* @param {ArrayLikeObject} y - output nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ -function map4d( x, y, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - if ( S0 <= 0 || S1 <= 0 || S2 <= 0 || S3 <= 0 ) { - return y; - } - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = y[ i3 ]; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = y2[ i2 ]; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = y1[ i1 ]; - for ( i0 = 0; i0 < S0; i0++ ) { - y0[ i0 ] = fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ); // eslint-disable-line max-len - } - } - } - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 935d75e..0000000 --- a/lib/index.js +++ /dev/null @@ -1,75 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array. -* -* @module @stdlib/array-base-map4d -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* var zeros4d = require( '@stdlib/array-base-zeros4d' ); -* var map4d = require( '@stdlib/array-base-map4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = zeros4d( shape ); -* -* var out = map4d.assign( x, y, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -* -* var bool = ( out === y ); -* // returns true -*/ - -// MODULES // - -var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' ); -var main = require( './main.js' ); -var assign = require( './assign.js' ); - - -// MAIN // - -setReadOnly( main, 'assign', assign ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 4d420aa..0000000 --- a/lib/main.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MAIN // - -/** -* Applies a function to elements in a four-dimensional nested input array and assigns results to elements in a new four-dimensional nested output array. -* -* @param {ArrayLikeObject} x - input nested array -* @param {NonNegativeIntegerArray} shape - array shape -* @param {Function} fcn - function to apply -* @param {*} [thisArg] - function execution context -* @returns {Array} output array -* -* @example -* var ones4d = require( '@stdlib/array-base-ones4d' ); -* -* function scale( x ) { -* return x * 10.0; -* } -* -* var shape = [ 1, 1, 2, 2 ]; -* -* var x = ones4d( shape ); -* var y = map4d( x, shape, scale ); -* // returns [ [ [ [ 10.0, 10.0 ], [ 10.0, 10.0 ] ] ] ] -*/ -function map4d( x, shape, fcn, thisArg ) { - var S0; - var S1; - var S2; - var S3; - var i0; - var i1; - var i2; - var i3; - var x0; - var y0; - var x1; - var y1; - var x2; - var y2; - var y; - - S0 = shape[ 3 ]; - S1 = shape[ 2 ]; - S2 = shape[ 1 ]; - S3 = shape[ 0 ]; - y = []; - for ( i3 = 0; i3 < S3; i3++ ) { - x2 = x[ i3 ]; - y2 = []; - for ( i2 = 0; i2 < S2; i2++ ) { - x1 = x2[ i2 ]; - y1 = []; - for ( i1 = 0; i1 < S1; i1++ ) { - x0 = x1[ i1 ]; - y0 = []; - for ( i0 = 0; i0 < S0; i0++ ) { - y0.push( fcn.call( thisArg, x0[ i0 ], [ i3, i2, i1, i0 ], x ) ); // eslint-disable-line max-len - } - y1.push( y0 ); - } - y2.push( y1 ); - } - y.push( y2 ); - } - return y; -} - - -// EXPORTS // - -module.exports = map4d; diff --git a/package.json b/package.json index 15799ee..5656cd8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.2", "description": "Apply a function to elements in a four-dimensional nested input array and assign results to elements in a new four-dimensional nested output array.", "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/types": "^0.4.3", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-filled4d-by": "^0.2.2", - "@stdlib/array-base-zeros4d": "^0.2.2", - "@stdlib/math-base-assert-is-nan": "^0.2.2", - "@stdlib/math-base-special-abs": "^0.2.2", - "@stdlib/math-base-special-floor": "^0.2.3", - "@stdlib/math-base-special-pow": "^0.3.0", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/number-float64-base-identity": "github:stdlib-js/number-float64-base-identity#main", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "@stdlib/random-base-uniform": "^0.2.1", - "@stdlib/utils-nary-function": "^0.2.2", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "base", @@ -86,9 +26,8 @@ "map", "transform" ], - "__stdlib__": {}, "funding": { "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..376e063 --- /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.assign.js b/test/test.assign.js deleted file mode 100644 index 9fcf4a4..0000000 --- a/test/test.assign.js +++ /dev/null @@ -1,272 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var zeros4d = require( '@stdlib/array-base-zeros4d' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ).assign; - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - y = zeros4d( shape ); - out = map4d( x, y, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var shape; - var out; - var x; - var y; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = zeros4d( shape ); - - y = zeros4d( shape ); - out = map4d( x, y, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - var y; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - y = zeros4d( shape ); - out = map4d( x, y, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( out, y, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index b278bac..0000000 --- a/test/test.js +++ /dev/null @@ -1,38 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'attached to the main export is an `assign` method', function test( t ) { - t.strictEqual( typeof map4d.assign, 'function', 'method is a function' ); - t.end(); -}); diff --git a/test/test.main.js b/test/test.main.js deleted file mode 100644 index 5701f22..0000000 --- a/test/test.main.js +++ /dev/null @@ -1,258 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 abs = require( '@stdlib/math-base-special-abs' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var map4d = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof map4d, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function applies a provided callback to a nested input array and assigns results to a nested output array', function test( t ) { - var expected; - var shape; - var out; - var x; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - out = map4d( x, shape, abs ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a first element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = []; - - out = map4d( x, [ 0, 1, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a second element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [] - ]; - - out = map4d( x, [ 1, 0, 2, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a third element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [] - ] - ]; - - out = map4d( x, [ 1, 1, 0, 2 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function does not invoke a provided callback if provided a shape having a fourth element equal to zero', function test( t ) { - var expected; - var out; - var x; - - x = [ - [ - [ - [ -1.0, -2.0 ], - [ -3.0, -4.0 ] - ] - ] - ]; - - expected = [ - [ - [ - [], - [] - ] - ] - ]; - - out = map4d( x, [ 1, 1, 2, 0 ], clbk ); - - t.deepEqual( out, expected, 'returns expected value' ); - t.end(); - - function clbk() { - t.ok( false, 'should not invoke callback' ); - } -}); - -tape( 'the function supports providing a function execution context', function test( t ) { - var expected; - var indices; - var values; - var arrays; - var shape; - var out; - var ctx; - var x; - - values = []; - indices = []; - arrays = []; - - shape = [ 1, 1, 2, 2 ]; - x = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - - ctx = { - 'count': 0 - }; - out = map4d( x, shape, fcn, ctx ); - - expected = [ - [ - [ - [ 1.0, 2.0 ], - [ 3.0, 4.0 ] - ] - ] - ]; - t.deepEqual( out, expected, 'returns expected value' ); - t.strictEqual( ctx.count, numel( shape ), 'returns expected value' ); - - expected = [ - 1.0, - 2.0, - 3.0, - 4.0 - ]; - t.deepEqual( values, expected, 'returns expected value' ); - - expected = [ - [ 0, 0, 0, 0 ], - [ 0, 0, 0, 1 ], - [ 0, 0, 1, 0 ], - [ 0, 0, 1, 1 ] - ]; - t.deepEqual( indices, expected, 'returns expected value' ); - - expected = [ - x, - x, - x, - x - ]; - t.deepEqual( arrays, expected, 'returns expected value' ); - - t.end(); - - function fcn( value, idx, array ) { - values.push( value ); - indices.push( idx ); - arrays.push( array ); - ctx.count += 1; - return value; - } -});