From 864f8cb37646245272f10ac3c7270926f471831f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 25 Sep 2025 16:00:21 +0000 Subject: [PATCH 01/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index ac1f941..ef90581 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.2", "@stdlib/ndarray-base-slice-from": "^0.2.2", "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 89ffef4dfe2d0f8272b06aa50b8156d686b4036b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 25 Sep 2025 16:01:13 +0000 Subject: [PATCH 02/39] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 49 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 43 files changed, 4869 insertions(+), 4474 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # 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 + + ```
@@ -187,7 +178,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 6a4183e..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('nullF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('nullF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d448ecb..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f492a5a..525ef91 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6a5bb9b --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ee5af50 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index ef90581..ca24b17 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "github:stdlib-js/array-base-nulls#main", - "@stdlib/ndarray-base-ndims": "^0.2.2", - "@stdlib/ndarray-base-normalize-index": "^0.2.2", - "@stdlib/ndarray-base-slice-from": "^0.2.2", - "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..450b0d1 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From 7d9543c7dd2e6253af09c0dbaf2649edccf83387 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Sep 2025 00:58:33 +0000 Subject: [PATCH 03/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index ac1f941..ef90581 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.2", "@stdlib/ndarray-base-slice-from": "^0.2.2", "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 56f157664a69827b3e05ef71562a5775057cf419 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Sep 2025 00:58:54 +0000 Subject: [PATCH 04/39] Remove files --- index.d.ts | 64 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4911 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 525ef91..0000000 --- a/index.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6a5bb9b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ee5af50..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 450b0d1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 852dabc9899dffeea3f76f3060b53503807e73c0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Sep 2025 00:59:26 +0000 Subject: [PATCH 05/39] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 50 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 43 files changed, 4868 insertions(+), 4474 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # 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 + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index d448ecb..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f492a5a..525ef91 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6a5bb9b --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ee5af50 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index ef90581..ca24b17 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "github:stdlib-js/array-base-nulls#main", - "@stdlib/ndarray-base-ndims": "^0.2.2", - "@stdlib/ndarray-base-normalize-index": "^0.2.2", - "@stdlib/ndarray-base-slice-from": "^0.2.2", - "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..450b0d1 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From 6d42a8ae51dea0fb1e93e510d132ab15363cb528 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Sep 2025 23:45:31 +0000 Subject: [PATCH 06/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index ac1f941..ef90581 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.2", "@stdlib/ndarray-base-slice-from": "^0.2.2", "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From d0e7f7e49d9fd61b162cc2cbfd89011874ce1967 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Sep 2025 23:45:50 +0000 Subject: [PATCH 07/39] Remove files --- index.d.ts | 64 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4911 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 525ef91..0000000 --- a/index.d.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6a5bb9b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ee5af50..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 450b0d1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From fd9b1ed3975b2db8e6cfe471cbad1f409cf74fa2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 29 Sep 2025 23:46:24 +0000 Subject: [PATCH 08/39] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 43 files changed, 4868 insertions(+), 4475 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # 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 + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6a5bb9b --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ee5af50 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index ef90581..ca24b17 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "github:stdlib-js/array-base-nulls#main", - "@stdlib/ndarray-base-ndims": "^0.2.2", - "@stdlib/ndarray-base-normalize-index": "^0.2.2", - "@stdlib/ndarray-base-slice-from": "^0.2.2", - "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..450b0d1 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From e5f8adc2209c572620aa8bf151d3cafb6c29f1cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 22 Dec 2025 00:37:09 +0000 Subject: [PATCH 09/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index ac1f941..ef90581 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.2", "@stdlib/ndarray-base-slice-from": "^0.2.2", "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From fdb5bb70c31b9e043d39e72b8dbe57b74221fde2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 22 Dec 2025 00:38:07 +0000 Subject: [PATCH 10/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6a5bb9b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ee5af50..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 450b0d1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 249e5275123202df977deddad06b1009507794d8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 22 Dec 2025 00:38:29 +0000 Subject: [PATCH 11/39] 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 | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 44 files changed, 4868 insertions(+), 4476 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 6cc4fe1..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-12-22T00:36:39.643Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # 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 + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..6a5bb9b --- /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 s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..ee5af50 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index ef90581..ca24b17 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "github:stdlib-js/array-base-nulls#main", - "@stdlib/ndarray-base-ndims": "^0.2.2", - "@stdlib/ndarray-base-normalize-index": "^0.2.2", - "@stdlib/ndarray-base-slice-from": "^0.2.2", - "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..450b0d1 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From 21e0e0e2d0d91b253ef77cfa45c6b6b0cd1c80ca Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 06:50:39 +0000 Subject: [PATCH 12/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index d06b52e..3592ef8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.2", "@stdlib/ndarray-base-slice-from": "^0.2.2", "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/string-format": "^0.2.2", + "@stdlib/error-tools-fmtprodmsg": "^0.2.2", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.2" }, From 9fd8bb9114e1460d7e0189c92b93272e5b8242f4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:52:13 +0000 Subject: [PATCH 13/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 6a5bb9b..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2025 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index ee5af50..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;2jBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 450b0d1..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1a44025c4a139d4d5b3f55da65562a9918b10f16 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 07:52:35 +0000 Subject: [PATCH 14/39] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 108 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 51 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 43 files changed, 4868 insertions(+), 4575 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..3e00e50 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..1f1bc97 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;whBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3592ef8..71d66b5 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.0", - "@stdlib/ndarray-base-ndims": "^0.2.2", - "@stdlib/ndarray-base-normalize-index": "^0.2.2", - "@stdlib/ndarray-base-slice-from": "^0.2.2", - "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.2" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-array": "^0.2.1", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/ndarray-empty": "^0.3.0", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.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.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b6a8e2b --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From e0e608ed50abb184f2111f1aa8ee1dbfef34c19a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:21:44 +0000 Subject: [PATCH 15/39] Update README.md for ESM bundle v0.1.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4447f1b..ade775f 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.0-esm/index.mjs'; ``` #### shift( x, dim, writable ) @@ -123,7 +123,7 @@ The function accepts the following arguments: import array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-array@esm/index.mjs'; import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.0-esm/index.mjs'; // Create a linear ndarray buffer: var buf = zeroTo( 27 ); From 9bc114177bf020c2bf46fb21190de39d115d026a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 31 Jan 2026 08:21:45 +0000 Subject: [PATCH 16/39] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ade775f..d8a970e 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@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/ndarray-base-shift/tags). For example, + ```javascript import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.0-esm/index.mjs'; ``` @@ -123,7 +128,7 @@ The function accepts the following arguments: import array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-array@esm/index.mjs'; import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.0-esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@esm/index.mjs'; // Create a linear ndarray buffer: var buf = zeroTo( 27 ); From 82e8129d53cb312830ed45bc555cc57df756ad9e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 8 Feb 2026 23:24:39 +0000 Subject: [PATCH 17/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index 94ff066..4fa14e4 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.3", "@stdlib/ndarray-base-slice-from": "^0.2.2", "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From d72dfc924cc1afa01e9514ed7cfb7d4f12dc2eae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:16:02 +0000 Subject: [PATCH 18/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3e00e50..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 1f1bc97..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;whBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b6a8e2b..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 42640b805ffb3998ac3d9b8f675ed3dbaea317c7 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:16:29 +0000 Subject: [PATCH 19/39] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 61 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 43 files changed, 4868 insertions(+), 4578 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..da5ff5f --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bad2d94 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 4fa14e4..54bf679 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.1", - "@stdlib/ndarray-base-ndims": "^0.2.3", - "@stdlib/ndarray-base-normalize-index": "^0.2.3", - "@stdlib/ndarray-base-slice-from": "^0.2.2", - "@stdlib/ndarray-base-slice-to": "^0.2.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-array": "^0.2.2", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.1", - "@stdlib/ndarray-zeros": "^0.3.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..8f744c0 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From 892664756dcd344de11a2374d06fd29079c96320 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:42:04 +0000 Subject: [PATCH 20/39] Update README.md for ESM bundle v0.1.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1cd53e6..32a140c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.1-esm/index.mjs'; ``` #### shift( x, dim, writable ) @@ -123,7 +123,7 @@ The function accepts the following arguments: import array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-array@esm/index.mjs'; import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.1-esm/index.mjs'; // Create a linear ndarray buffer: var buf = zeroTo( 27 ); From 930c51c724f76acbfe18b9138eb6621129109330 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 9 Feb 2026 00:42:05 +0000 Subject: [PATCH 21/39] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32a140c..aef514f 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@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/ndarray-base-shift/tags). For example, + ```javascript import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.1-esm/index.mjs'; ``` @@ -123,7 +128,7 @@ The function accepts the following arguments: import array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-array@esm/index.mjs'; import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; -import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@v0.1.1-esm/index.mjs'; +import shift from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-shift@esm/index.mjs'; // Create a linear ndarray buffer: var buf = zeroTo( 27 ); From 558388a2690222fb0aa6946f707ed4d753965fbe Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Feb 2026 00:50:54 +0000 Subject: [PATCH 22/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index 34cb4ea..3396d72 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.3", "@stdlib/ndarray-base-slice-from": "^0.2.3", "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 2588f31f85cd4bb97779cab48853523401704e81 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Feb 2026 01:01:50 +0000 Subject: [PATCH 23/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index da5ff5f..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bad2d94..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 8f744c0..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From daf852c2846e70d417ff4d291fc8f3b321427e0c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 23 Feb 2026 01:02:32 +0000 Subject: [PATCH 24/39] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 61 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 44 files changed, 4868 insertions(+), 4579 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index dab5d2a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,180 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d79cb26..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-02-23T00:46:57.169Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c115ea7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bad2d94 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3396d72..54bf679 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.1", - "@stdlib/ndarray-base-ndims": "^0.2.3", - "@stdlib/ndarray-base-normalize-index": "^0.2.3", - "@stdlib/ndarray-base-slice-from": "^0.2.3", - "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1a4a914 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From ae1fb820a581828957298ae43f6778016108443b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:27:01 +0000 Subject: [PATCH 25/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index 34cb4ea..3396d72 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.3", "@stdlib/ndarray-base-slice-from": "^0.2.3", "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 5d66907d7b14c6388079908fa0daad644dec5937 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:41:57 +0000 Subject: [PATCH 26/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c115ea7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bad2d94..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1a4a914..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5b2200f0fc92aed90a251cdc7516c431248542f9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 10 Apr 2026 03:42:18 +0000 Subject: [PATCH 27/39] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 199 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 61 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 190 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 44 files changed, 4868 insertions(+), 4590 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 295a5fb..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-04-10T03:22:48.016Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 121b0e1..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,190 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( pkg+'::1d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::2d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::3d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::4d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+'::5d', function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c115ea7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bad2d94 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3396d72..54bf679 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.1", - "@stdlib/ndarray-base-ndims": "^0.2.3", - "@stdlib/ndarray-base-normalize-index": "^0.2.3", - "@stdlib/ndarray-base-slice-from": "^0.2.3", - "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1a4a914 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From cc50f8c5e709efc3a21860a4bb5c7e84e2a867a3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 May 2026 23:54:14 +0000 Subject: [PATCH 28/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index 34cb4ea..3396d72 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.3", "@stdlib/ndarray-base-slice-from": "^0.2.3", "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 6331ac5783a2bce398edee781523e54a291a636a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 May 2026 23:57:56 +0000 Subject: [PATCH 29/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c115ea7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bad2d94..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1a4a914..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 29d4c479e990779db14b385856414881cd1b032d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 18 May 2026 23:58:21 +0000 Subject: [PATCH 30/39] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 96 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 191 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 43 files changed, 4868 insertions(+), 4630 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fcc523d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,191 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::1d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::2d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::3d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::4d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::5d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c115ea7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bad2d94 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3396d72..54bf679 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.1", - "@stdlib/ndarray-base-ndims": "^0.2.3", - "@stdlib/ndarray-base-normalize-index": "^0.2.3", - "@stdlib/ndarray-base-slice-from": "^0.2.3", - "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1a4a914 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From 168e20a2da0ba26923cb8bd8db4ee4fe8075648e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:30:13 +0000 Subject: [PATCH 31/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index 34cb4ea..3396d72 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.3", "@stdlib/ndarray-base-slice-from": "^0.2.3", "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.4.3", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 15d05597b1072a6fc2f559a5f53e716758779597 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:42:44 +0000 Subject: [PATCH 32/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c115ea7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bad2d94..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1a4a914..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5936439c530f7569591ca1044c8753a6ef79c0cd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 21 May 2026 03:43:13 +0000 Subject: [PATCH 33/39] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 96 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 191 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 44 files changed, 4868 insertions(+), 4644 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 66c02cd..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-05-21T03:27:39.234Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fcc523d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,191 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::1d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::2d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::3d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::4d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::5d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index be22e1f..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){return r||n((r={exports:{}}).exports,r),r.exports}};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,a){var s,o,e,i;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return i=c(e),i[r]=1,s=l(n,i,!1,a),o=q(n,i,!1,a),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 57862b9..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c115ea7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bad2d94 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index 3396d72..54bf679 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.1", - "@stdlib/ndarray-base-ndims": "^0.2.3", - "@stdlib/ndarray-base-normalize-index": "^0.2.3", - "@stdlib/ndarray-base-slice-from": "^0.2.3", - "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.4.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1a4a914 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From c5e2c4edf7c2f9e8447c87fc0c4e86bad89fa095 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:39:01 +0000 Subject: [PATCH 34/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index fd427c5..c86d2a8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.3", "@stdlib/ndarray-base-slice-from": "^0.2.3", "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From bd7fb971f10751692294a771132d024061e75c67 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:57:05 +0000 Subject: [PATCH 35/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c115ea7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bad2d94..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1a4a914..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d4ab506e5e77f59635c00e50a64457b7a91aa536 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Jul 2026 03:57:29 +0000 Subject: [PATCH 36/39] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 204 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 96 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 191 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 44 files changed, 4868 insertions(+), 4644 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 16bc24d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-07-01T03:32:36.602Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fcc523d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,191 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::1d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::2d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::3d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::4d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::5d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 413afa3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){try{return r||n((r={exports:{}}).exports,r),r.exports}catch(i){throw (r=0, i)}};};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,i){var s,o,e,a;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return a=c(e),a[r]=1,s=l(n,a,!1,i),o=q(n,a,!1,i),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 369a925..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c115ea7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bad2d94 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index c86d2a8..54bf679 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.1", - "@stdlib/ndarray-base-ndims": "^0.2.3", - "@stdlib/ndarray-base-normalize-index": "^0.2.3", - "@stdlib/ndarray-base-slice-from": "^0.2.3", - "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1a4a914 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -}); From 30e54e9b0a6e1e0a5f9a86c3d0ae603827b3aae2 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 03:35:22 +0000 Subject: [PATCH 37/39] Transform error messages --- lib/main.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 8d11a48..15295c1 100644 --- a/lib/main.js +++ b/lib/main.js @@ -25,7 +25,7 @@ var ndims = require( '@stdlib/ndarray-base-ndims' ); var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -75,12 +75,12 @@ function shift( x, dim, writable ) { // Check whether we were provided a zero-dimensional array... if ( N === 0 ) { - throw new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) ); + throw new TypeError( format( 'nullF7', N ) ); } // Normalize the dimension index: dim = normalizeIndex( dim, N-1 ); if ( dim === -1 ) { - throw new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) ); + throw new RangeError( format( 'nullF8', N, dim ) ); } // Define a list of slice arguments: s = nulls( N ); diff --git a/package.json b/package.json index fd427c5..c86d2a8 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@stdlib/ndarray-base-normalize-index": "^0.2.3", "@stdlib/ndarray-base-slice-from": "^0.2.3", "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/string-format": "^0.2.3", + "@stdlib/error-tools-fmtprodmsg": "^0.2.3", "@stdlib/types": "^0.5.1", "@stdlib/error-tools-fmtprodmsg": "^0.2.3" }, From 76b6b4c8ae2aea3e058f0884a2da014c2dbf9341 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 04:01:41 +0000 Subject: [PATCH 38/39] Remove files --- index.d.ts | 68 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4915 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 6e84b89..0000000 --- a/index.d.ts +++ /dev/null @@ -1,68 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* ## Notes -* -* - The input array must have one or more dimensions. -* -* @param x - input array -* @param dim - dimension along which to perform the operation -* @param writable - boolean indicating whether returned arrays should be writable -* @returns a list of ndarrays -* -* @example -* var Float64Array = require( '@stdlib/array-float64' ); -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -declare function shift( x: T, dim: number, writable: boolean ): [ T, T ]; - - -// EXPORTS // - -export = shift; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index c115ea7..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index bad2d94..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1a4a914..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 387717362a17129e43a44d94dc546ab04744bcd0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 19 Aug 2026 04:02:10 +0000 Subject: [PATCH 39/39] Auto-generated commit --- .editorconfig | 189 - .eslintrc.js | 1 - .gitattributes | 68 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 821 --- .github/workflows/publish.yml | 261 - .github/workflows/test.yml | 101 - .github/workflows/test_bundles.yml | 213 - .github/workflows/test_coverage.yml | 142 - .github/workflows/test_install.yml | 94 - .github/workflows/test_published_package.yml | 115 - .gitignore | 205 - .npmignore | 229 - .npmrc | 44 - CHANGELOG.md | 96 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 45 +- SECURITY.md | 5 - benchmark/benchmark.js | 191 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 39 - docs/types/test.ts | 81 - examples/index.js | 39 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 59 - lib/main.js | 101 - package.json | 67 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 425 -- 44 files changed, 4868 insertions(+), 4645 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .github/workflows/test_published_package.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 branches.md delete mode 100644 dist/index.d.ts delete mode 100644 dist/index.js delete mode 100644 dist/index.js.map delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (95%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/dist/test.js delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 80f3fca..0000000 --- a/.editorconfig +++ /dev/null @@ -1,189 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Ignore generated lock files for GitHub Agentic Workflows: -[*.lock.yml] -charset = unset -end_of_line = unset -indent_style = unset -indent_size = unset -trim_trailing_whitespace = unset -insert_final_newline = unset - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 24b327f..0000000 --- a/.gitattributes +++ /dev/null @@ -1,68 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation - -.github/workflows/*.lock.yml linguist-generated=true merge=ours diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 0f4644d..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2026-08-19T03:24:52.739Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 6a03010..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/ndarray/base/shift) 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 454966d..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/ndarray/base/shift) 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 7ea4087..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: '35 11 * * 4' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 83d50c4..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,821 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send notification to Zulip if job fails: - - name: 'Send notification to Zulip in case of failure' - # Pin action to full length commit SHA - uses: zulip/github-actions-zulip/send-message@e4c8f27c732ba9bd98ac6be0583096dea82feea5 # v1.0.2 - if: failure() - with: - api-key: ${{ secrets.ZULIP_API_KEY }} - email: 'github-actions-bot@stdlib.zulipchat.com' - organization-url: 'https://stdlib.zulipchat.com' - to: 'workflows-standalone' - type: 'stream' - topic: ${{ github.event.repository.name }} - content: | - :cross_mark: **${{ github.workflow }}** workflow failed - - **Repository:** [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) - **Run:** [View workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure Git: - - name: 'Configure Git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -183,7 +174,7 @@ console.log( ndarray2array( y[ 1 ] ) ); ## Notice -This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. +This package is part of [stdlib][stdlib], a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index fcc523d..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,191 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench-harness' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var empty = require( '@stdlib/ndarray-empty' ); -var format = require( '@stdlib/string-format' ); -var pkg = require( './../package.json' ).name; -var shift = require( './../lib' ); - - -// MAIN // - -bench( format( '%s::1d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2 ], { 'dtype': 'float64' } ), - empty( [ 2 ], { 'dtype': 'float32' } ), - empty( [ 2 ], { 'dtype': 'int32' } ), - empty( [ 2 ], { 'dtype': 'complex128' } ), - empty( [ 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::2d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::3d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::4d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( format( '%s::5d', pkg ), function benchmark( b ) { - var values; - var v; - var i; - - /* eslint-disable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - values = [ - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float64' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'float32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'int32' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'complex128' } ), - empty( [ 2, 2, 2, 2, 2 ], { 'dtype': 'generic' } ) - ]; - - /* eslint-enable object-curly-newline, stdlib/line-closing-bracket-spacing */ - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - v = shift( values[ i%values.length ], 0, false ); - if ( typeof v !== 'object' ) { - b.fail( 'should return an array of ndarrays' ); - } - } - b.toc(); - if ( !isndarrayLike( v[0] ) || !isndarrayLike( v[1] ) ) { - b.fail( 'should return an array of ndarrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/branches.md b/branches.md deleted file mode 100644 index fda816c..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/ndarray/base/shift" -%% click B href "https://github.com/stdlib-js/ndarray-base-shift/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-base-shift/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-base-shift/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-base-shift/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-base-shift/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/base/shift -[production-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-base-shift/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-base-shift/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-base-shift/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 1105c44..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import shift from '../docs/types/index'; -export = shift; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 413afa3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var m=function(n,r){return function(){try{return r||n((r={exports:{}}).exports,r),r.exports}catch(i){throw (r=0, i)}};};var v=m(function(p,t){ -var d=require('@stdlib/ndarray-base-normalize-index/dist'),f=require('@stdlib/ndarray-base-ndims/dist'),l=require('@stdlib/ndarray-base-slice-from/dist'),q=require('@stdlib/ndarray-base-slice-to/dist'),c=require('@stdlib/array-base-nulls/dist'),u=require('@stdlib/error-tools-fmtprodmsg/dist');function g(n,r,i){var s,o,e,a;if(e=f(n),e===0)throw new TypeError(u('2WdF7',e));if(r=d(r,e-1),r===-1)throw new RangeError(u('2WdF8',e,r));return a=c(e),a[r]=1,s=l(n,a,!1,i),o=q(n,a,!1,i),[s,o]}t.exports=g -});var h=v();module.exports=h; -/** @license Apache-2.0 */ -//# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map deleted file mode 100644 index 369a925..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' );\nvar ndims = require( '@stdlib/ndarray-base-ndims' );\nvar sliceFrom = require( '@stdlib/ndarray-base-slice-from' );\nvar sliceTo = require( '@stdlib/ndarray-base-slice-to' );\nvar nulls = require( '@stdlib/array-base-nulls' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must be an ndarray having one or more dimensions. Number of dimensions: %d.', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'invalid argument. Dimension index exceeds the number of dimensions. Number of dimensions: %d. Value: `%d`.', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nmodule.exports = shift;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @module @stdlib/ndarray-base-shift\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n* var shift = require( '@stdlib/ndarray-base-shift' );\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "iIAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAiB,QAAS,sCAAuC,EACjEC,EAAQ,QAAS,4BAA6B,EAC9CC,EAAY,QAAS,iCAAkC,EACvDC,EAAU,QAAS,+BAAgC,EACnDC,EAAQ,QAAS,0BAA2B,EAC5CC,EAAS,QAAS,uBAAwB,EAuC9C,SAASC,EAAOC,EAAGC,EAAKC,EAAW,CAClC,IAAIC,EACAC,EACAC,EACAC,EAMJ,GAHAD,EAAIX,EAAOM,CAAE,EAGRK,IAAM,EACV,MAAM,IAAI,UAAWP,EAAQ,+GAAgHO,CAAE,CAAE,EAIlJ,GADAJ,EAAMR,EAAgBQ,EAAKI,EAAE,CAAE,EAC1BJ,IAAQ,GACZ,MAAM,IAAI,WAAYH,EAAQ,6GAA8GO,EAAGJ,CAAI,CAAE,EAGtJ,OAAAK,EAAIT,EAAOQ,CAAE,EACbC,EAAGL,CAAI,EAAI,EAGXE,EAAKR,EAAWK,EAAGM,EAAG,GAAOJ,CAAS,EAGtCE,EAAKR,EAASI,EAAGM,EAAG,GAAOJ,CAAS,EAE7B,CAAEC,EAAIC,CAAG,CACjB,CAKAZ,EAAO,QAAUO,IC/CjB,IAAIQ,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "normalizeIndex", "ndims", "sliceFrom", "sliceTo", "nulls", "format", "shift", "x", "dim", "writable", "v0", "v1", "N", "s", "main"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index bca8a6b..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,39 +0,0 @@ - -{{alias}}( x, dim, writable ) - Returns an array containing a truncated view of an input ndarray and a view - of the first element(s) along a specified dimension. - - Parameters - ---------- - x: ndarray - Input array. Must have one or more dimensions. - - dim: integer - Dimension along which to perform the operation. If provided an integer - less than zero, the dimension index is resolved relative to the last - dimension, with the last dimension corresponding to the value `-1`. - - writable: boolean - Boolean indicating whether a returned ndarray should be writable. This - parameter only applies to ndarray constructors which support read-only - instances. - - Returns - ------- - out: Array - An array containing a truncated view of an input ndarray and a view of - the first element(s) along a specified dimension. - - Examples - -------- - > var x = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ) - - > var y = {{alias}}( x, 1, false ) - [ , ] - > {{alias:@stdlib/ndarray/to-array}}( y[0] ) - [ [ 2 ], [ 4 ] ] - > {{alias:@stdlib/ndarray/to-array}}( y[1] ) - [ [ 1 ], [ 3 ] ] - - See Also - -------- diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index be829c0..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -import empty = require( '@stdlib/ndarray-base-empty' ); -import shift = require( './index' ); - - -// TESTS // - -// The function returns an array of ndarrays... -{ - const order = 'row-major'; - const sh = [ 2, 2 ]; - - shift( empty( 'float64', sh, order ), 1, false ); // $ExpectType [float64ndarray, float64ndarray] - shift( empty( 'complex64', sh, order ), 1, false ); // $ExpectType [complex64ndarray, complex64ndarray] - shift( empty( 'uint8', sh, order ), 1, false ); // $ExpectType [uint8ndarray, uint8ndarray] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - shift( '10', 1, false ); // $ExpectError - shift( 10, 1, false ); // $ExpectError - shift( false, 1, false ); // $ExpectError - shift( true, 1, false ); // $ExpectError - shift( null, 1, false ); // $ExpectError - shift( [], 1, false ); // $ExpectError - shift( {}, 1, false ); // $ExpectError - shift( ( x: number ): number => x, 1, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a second argument which is not an integer... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, '5', false ); // $ExpectError - shift( x, false, false ); // $ExpectError - shift( x, true, false ); // $ExpectError - shift( x, null, false ); // $ExpectError - shift( x, undefined, false ); // $ExpectError - shift( x, [ '5' ], false ); // $ExpectError - shift( x, {}, false ); // $ExpectError - shift( x, ( x: number ): number => x, false ); // $ExpectError -} - -// The compiler throws an error if the function is provided a third argument which is not a boolean... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x, 1, '5' ); // $ExpectError - shift( x, 1, 5 ); // $ExpectError - shift( x, 1, null ); // $ExpectError - shift( x, 1, undefined ); // $ExpectError - shift( x, 1, [ '5' ] ); // $ExpectError - shift( x, 1, {} ); // $ExpectError - shift( x, 1, ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const x = empty( 'float64', [ 2, 2 ], 'row-major' ); - - shift( x ); // $ExpectError - shift( x, 1 ); // $ExpectError - shift( x, 1, false, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index c92e125..0000000 --- a/examples/index.js +++ /dev/null @@ -1,39 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -var array = require( '@stdlib/ndarray-array' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var shift = require( './../lib' ); - -// Create a linear ndarray buffer: -var buf = zeroTo( 27 ); - -// Create an ndarray: -var x = array( buf, { - 'shape': [ 3, 3, 3 ] -}); -console.log( ndarray2array( x ) ); - -// Remove the first row from each matrix: -var y = shift( x, 1, false ); - -console.log( ndarray2array( y[ 0 ] ) ); -console.log( ndarray2array( y[ 1 ] ) ); diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 95% rename from docs/types/index.d.ts rename to index.d.ts index f816c3f..6e84b89 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 4.1 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c115ea7 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-normalize-index@v0.2.3-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndims@v0.2.3-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-from@v0.2.3-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-slice-to@v0.2.3-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/array-base-nulls@v0.1.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.3-esm/index.mjs";function i(i,m,o){var l,a;if(0===(l=r(i)))throw new TypeError(d("nullF7",l));if(-1===(m=s(m,l-1)))throw new RangeError(d("nullF8",l,m));return(a=n(l))[m]=1,[e(i,a,!1,o),t(i,a,!1,o)]}export{i as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..bad2d94 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2025 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport normalizeIndex from '@stdlib/ndarray-base-normalize-index';\nimport ndims from '@stdlib/ndarray-base-ndims';\nimport sliceFrom from '@stdlib/ndarray-base-slice-from';\nimport sliceTo from '@stdlib/ndarray-base-slice-to';\nimport nulls from '@stdlib/array-base-nulls';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.\n*\n* @param {ndarray} x - input array\n* @param {integer} dim - dimension along which to perform the operation\n* @param {boolean} writable - boolean indicating whether returned arrays should be writable\n* @throws {TypeError} first argument must be an ndarray having one or more dimensions\n* @throws {RangeError} dimension index exceeds the number of dimensions\n* @returns {Array} a list of ndarrays\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n* import ndarray2array from '@stdlib/ndarray-to-array';\n*\n* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ];\n* var shape = [ 3, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' );\n* // returns \n*\n* var arr = ndarray2array( x );\n* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* var y = shift( x, 0, false );\n* // returns [ , ]\n*\n* arr = ndarray2array( y[ 0 ] );\n* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]\n*\n* arr = ndarray2array( y[ 1 ] );\n* // returns [ [ 1.0, 2.0 ] ]\n*/\nfunction shift( x, dim, writable ) {\n\tvar v0;\n\tvar v1;\n\tvar N;\n\tvar s;\n\n\t// Retrieve array meta data:\n\tN = ndims( x );\n\n\t// Check whether we were provided a zero-dimensional array...\n\tif ( N === 0 ) {\n\t\tthrow new TypeError( format( 'nullF7', N ) );\n\t}\n\t// Normalize the dimension index:\n\tdim = normalizeIndex( dim, N-1 );\n\tif ( dim === -1 ) {\n\t\tthrow new RangeError( format( 'nullF8', N, dim ) );\n\t}\n\t// Define a list of slice arguments:\n\ts = nulls( N );\n\ts[ dim ] = 1;\n\n\t// Create a truncated view:\n\tv0 = sliceFrom( x, s, false, writable );\n\n\t// Create a view of the first element(s):\n\tv1 = sliceTo( x, s, false, writable );\n\n\treturn [ v0, v1 ];\n}\n\n\n// EXPORTS //\n\nexport default shift;\n"],"names":["shift","x","dim","writable","N","s","ndims","TypeError","format","normalizeIndex","RangeError","nulls","sliceFrom","sliceTo"],"mappings":";;kkBAkEA,SAASA,EAAOC,EAAGC,EAAKC,GACvB,IAEIC,EACAC,EAMJ,GAAW,KAHXD,EAAIE,EAAOL,IAIV,MAAM,IAAIM,UAAWC,EAAQ,SAAUJ,IAIxC,IAAc,KADdF,EAAMO,EAAgBP,EAAKE,EAAE,IAE5B,MAAM,IAAIM,WAAYF,EAAQ,SAAUJ,EAAGF,IAY5C,OATAG,EAAIM,EAAOP,IACRF,GAAQ,EAQJ,CALFU,EAAWX,EAAGI,GAAG,EAAOF,GAGxBU,EAASZ,EAAGI,GAAG,EAAOF,GAG5B"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index f07570d..0000000 --- a/lib/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @module @stdlib/ndarray-base-shift -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* var shift = require( '@stdlib/ndarray-base-shift' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ - -// MODULES // - -var main = require( './main.js' ); - - -// EXPORTS // - -module.exports = main; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 15295c1..0000000 --- a/lib/main.js +++ /dev/null @@ -1,101 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var normalizeIndex = require( '@stdlib/ndarray-base-normalize-index' ); -var ndims = require( '@stdlib/ndarray-base-ndims' ); -var sliceFrom = require( '@stdlib/ndarray-base-slice-from' ); -var sliceTo = require( '@stdlib/ndarray-base-slice-to' ); -var nulls = require( '@stdlib/array-base-nulls' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Returns an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension. -* -* @param {ndarray} x - input array -* @param {integer} dim - dimension along which to perform the operation -* @param {boolean} writable - boolean indicating whether returned arrays should be writable -* @throws {TypeError} first argument must be an ndarray having one or more dimensions -* @throws {RangeError} dimension index exceeds the number of dimensions -* @returns {Array} a list of ndarrays -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ]; -* var shape = [ 3, 2 ]; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var x = ndarray( 'generic', buffer, shape, strides, offset, 'row-major' ); -* // returns -* -* var arr = ndarray2array( x ); -* // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* var y = shift( x, 0, false ); -* // returns [ , ] -* -* arr = ndarray2array( y[ 0 ] ); -* // returns [ [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] -* -* arr = ndarray2array( y[ 1 ] ); -* // returns [ [ 1.0, 2.0 ] ] -*/ -function shift( x, dim, writable ) { - var v0; - var v1; - var N; - var s; - - // Retrieve array meta data: - N = ndims( x ); - - // Check whether we were provided a zero-dimensional array... - if ( N === 0 ) { - throw new TypeError( format( 'nullF7', N ) ); - } - // Normalize the dimension index: - dim = normalizeIndex( dim, N-1 ); - if ( dim === -1 ) { - throw new RangeError( format( 'nullF8', N, dim ) ); - } - // Define a list of slice arguments: - s = nulls( N ); - s[ dim ] = 1; - - // Create a truncated view: - v0 = sliceFrom( x, s, false, writable ); - - // Create a view of the first element(s): - v1 = sliceTo( x, s, false, writable ); - - return [ v0, v1 ]; -} - - -// EXPORTS // - -module.exports = shift; diff --git a/package.json b/package.json index c86d2a8..54bf679 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.1", "description": "Return an array containing a truncated view of an input ndarray and a view of the first element(s) along a specified dimension.", "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,46 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/array-base-nulls": "^0.1.1", - "@stdlib/ndarray-base-ndims": "^0.2.3", - "@stdlib/ndarray-base-normalize-index": "^0.2.3", - "@stdlib/ndarray-base-slice-from": "^0.2.3", - "@stdlib/ndarray-base-slice-to": "^0.2.3", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3", - "@stdlib/types": "^0.5.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.3" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.2", - "@stdlib/assert-is-ndarray-like": "^0.2.3", - "@stdlib/ndarray-array": "^0.2.3", - "@stdlib/ndarray-base-assert-is-read-only": "^0.2.3", - "@stdlib/ndarray-ctor": "^0.3.1", - "@stdlib/ndarray-empty": "^0.3.1", - "@stdlib/ndarray-shape": "^0.2.3", - "@stdlib/ndarray-to-array": "^0.2.2", - "@stdlib/ndarray-zeros": "^0.3.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.3" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1a4a914 --- /dev/null +++ b/stats.html @@ -0,0 +1,4842 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 0a7552a..0000000 --- a/test/test.js +++ /dev/null @@ -1,425 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2025 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var isReadOnly = require( '@stdlib/ndarray-base-assert-is-read-only' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var zeros = require( '@stdlib/ndarray-zeros' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var ndarray2array = require( '@stdlib/ndarray-to-array' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var shift = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof shift, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if provided a zero-dimensional array', function test( t ) { - var values; - var i; - - values = [ - zeros( [] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error' ); - } - t.end(); - - function badValue( x ) { - return function badValue() { - shift( x, 0, false ); - }; - } -}); - -tape( 'the function throws an error if the dimension index exceeds the number of dimensions', function test( t ) { - var values; - var i; - - values = [ - zeros( [ 1 ] ), - zeros( [ 1, 1 ] ), - zeros( [ 1, 1, 1 ] ), - zeros( [ 1, 1, 1, 1 ] ) - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ], 10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - t.throws( badValue( values[ i ], -10 ), RangeError, 'throws an error when provided ' + values[ i ].shape.join( 'x' ) ); - } - t.end(); - - function badValue( x, dim ) { - return function badValue() { - shift( x, dim, false ); - }; - } -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=1, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 6, 'float64' ); - sh = [ 6 ]; - st = [ 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 5 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ 1, 2, 3, 4, 5 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ 0 ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=2, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 4 ]; - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 4, 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0, 1, 2, 3 ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ 1, 2, 3 ], [ 5, 6, 7 ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ 0 ], [ 4 ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, readonly)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, 2, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns an array containing ndarrays (ndims=3, writable)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - sh = [ 2, 2, 2 ]; - st = [ 4, 2, 1 ]; - o = 0; - ord = 'row-major'; - - /* - * [ - * [ - * [ 0, 1 ], - * [ 2, 3 ] - * ], - * [ - * [ 4, 5 ], - * [ 6, 7 ] - * ] - *]; - */ - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, -3, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 2, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 4, 5 ], [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ], [ 2, 3 ] ] ], 'returns expected value' ); - - actual = shift( x, -2, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 1, 2 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 2, 3 ] ], [ [ 6, 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0, 1 ] ], [ [ 4, 5 ] ] ], 'returns expected value' ); - - actual = shift( x, -1, true ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), false, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), false, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 2, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [ [ [ 1 ], [ 3 ] ], [ [ 5 ], [ 7 ] ] ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [ [ [ 0 ], [ 2 ] ], [ [ 4 ], [ 6 ] ] ], 'returns expected value' ); - - t.end(); -}); - -tape( 'the function returns empty views if provided an empty array (ndims=2)', function test( t ) { - var actual; - var buf; - var ord; - var sh; - var st; - var o; - var x; - - buf = zeroTo( 8, 'float64' ); - st = [ 4, 1 ]; - o = 0; - ord = 'row-major'; - - sh = [ 2, 0 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 1, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 2, 0 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - sh = [ 0, 4 ]; - x = new ndarray( 'float64', buf, sh, st, o, ord ); - - actual = shift( x, 0, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 4 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - actual = shift( x, 1, false ); - - t.strictEqual( isndarrayLike( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isndarrayLike( actual[1] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[0] ), true, 'returns expected value' ); - t.strictEqual( isReadOnly( actual[1] ), true, 'returns expected value' ); - t.deepEqual( getShape( actual[0] ), [ 0, 3 ], 'returns expected value' ); - t.deepEqual( getShape( actual[1] ), [ 0, 1 ], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[0] ), [], 'returns expected value' ); - t.deepEqual( ndarray2array( actual[1] ), [], 'returns expected value' ); - - t.end(); -});