From ad9043454f316a6b753659763fb9d6af317b55d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Mar 2023 00:11:39 +0000 Subject: [PATCH 01/58] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7434e58..fc432be 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toArray = require( '@stdlib/ndarray-base-to-array' ); diff --git a/package.json b/package.json index a270d19..25f6d9e 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-ndarray-like": "^0.0.6", "@stdlib/ndarray-base-to-array": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 018ea8af65998173d0230aa344008be3821057ef Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 5 Mar 2023 00:15:17 +0000 Subject: [PATCH 02/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 236 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 61 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 422 -- 37 files changed, 6205 insertions(+), 4107 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8b42ff3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3eb7ca5..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 3e8e2db..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v1 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -171,7 +164,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -231,7 +224,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 2f13aa5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( arr ) - Converts an ndarray to a generic array. - - Parameters - ---------- - arr: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 01a74a9..31c9d6d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08194d5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("invalid argument. Must provide an ndarray. Value: `%s`.",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5871db4 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;oRAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index fc432be..0000000 --- a/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} arr - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( arr ) { - if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) ); - } - return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 25f6d9e..811a485 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/ndarray-base-to-array": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-array-array": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.1", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -91,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..93fc1a5 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9e4d063..0000000 --- a/test/test.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 290df203305e2a29ea711e8ff043f1ebbc893276 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:24:09 +0000 Subject: [PATCH 03/58] Transform error messages --- lib/main.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7434e58..fc432be 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toArray = require( '@stdlib/ndarray-base-to-array' ); diff --git a/package.json b/package.json index a29eeef..6060ff9 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-ndarray-like": "^0.0.6", "@stdlib/ndarray-base-to-array": "^0.0.7", - "@stdlib/string-format": "^0.0.3", + "@stdlib/error-tools-fmtprodmsg": "^0.0.2", "@stdlib/types": "^0.0.14" }, "devDependencies": { From 753f9607f2763078dbb5a693c75322b702fc66c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:24:35 +0000 Subject: [PATCH 04/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 31c9d6d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param arr - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( array: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08194d5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("invalid argument. Must provide an ndarray. Value: `%s`.",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5871db4..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;oRAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 93fc1a5..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From ff53b46c05ac1a4dbba297741af9d00c0973a52a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:25:35 +0000 Subject: [PATCH 05/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 798 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 61 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 422 -- 37 files changed, 6205 insertions(+), 4113 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py delete mode 100644 branches.md delete mode 100644 docs/repl.txt delete mode 100644 docs/types/test.ts delete mode 100644 examples/index.js rename docs/types/index.d.ts => index.d.ts (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 0fd4d6c..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8b42ff3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3eb7ca5..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 334eb59..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,798 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Format error messages: - - name: 'Replace double quotes with single quotes in rewritten format string error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\( \"([a-zA-Z0-9]+)\"/Error\( format\( '\1'/g" {} \; - - # Format string literal error messages: - - name: 'Replace double quotes with single quotes in rewritten string literal error messages' - run: | - find . -name "*.js" -exec sed -E -i "s/Error\( format\(\"([a-zA-Z0-9]+)\"\)/Error\( format\( '\1' \)/g" {} \; - - # Format code: - - name: 'Replace double quotes with single quotes in inserted `require` calls' - run: | - find . -name "*.js" -exec sed -E -i "s/require\( ?\"@stdlib\/error-tools-fmtprodmsg\" ?\);/require\( '@stdlib\/error-tools-fmtprodmsg' \);/g" {} \; - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -171,7 +164,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -231,7 +224,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 2f13aa5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( arr ) - Converts an ndarray to a generic array. - - Parameters - ---------- - arr: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 01a74a9..31c9d6d 100644 --- a/docs/types/index.d.ts +++ b/index.d.ts @@ -18,7 +18,7 @@ // TypeScript Version: 2.0 -/// +/// import { ndarray } from '@stdlib/types/ndarray'; diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..08194d5 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("invalid argument. Must provide an ndarray. Value: `%s`.",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..5871db4 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;oRAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index fc432be..0000000 --- a/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} arr - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( arr ) { - if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) ); - } - return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 6060ff9..62032ac 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.0.1", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.0.6", - "@stdlib/ndarray-base-to-array": "^0.0.7", - "@stdlib/error-tools-fmtprodmsg": "^0.0.2", - "@stdlib/types": "^0.0.14" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.0.6", - "@stdlib/array-complex64": "^0.0.6", - "@stdlib/assert-is-array": "^0.0.7", - "@stdlib/assert-is-array-array": "^0.0.7", - "@stdlib/bench": "^0.0.12", - "@stdlib/complex-imagf": "^0.0.1", - "@stdlib/complex-realf": "^0.0.1", - "@stdlib/ndarray-base-numel": "^0.0.8", - "@stdlib/ndarray-base-shape2strides": "^0.0.8", - "@stdlib/ndarray-base-strides2offset": "^0.0.8", - "@stdlib/ndarray-ctor": "^0.0.10", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -91,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..e0aba60 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9e4d063..0000000 --- a/test/test.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 81d023331878f9bad6daba4cdfe4e1494601194f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:26:40 +0000 Subject: [PATCH 06/58] Update README.md for ESM bundle v0.0.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0dd7100..55f6c1c 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ limitations under the License. ## Usage ```javascript -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.0.1-esm/index.mjs'; ``` #### ndarray2array( arr ) @@ -95,7 +95,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.0.1-esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From 13e1e73798b5577bea30793b3b358abb4626d748 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 31 Jul 2023 15:26:42 +0000 Subject: [PATCH 07/58] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 55f6c1c..5991ec0 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,11 @@ limitations under the License. ## Usage +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@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-to-array/tags). For example, + ```javascript import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.0.1-esm/index.mjs'; ``` @@ -95,7 +100,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.0.1-esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From 0b7577d2396221a311afc6db665a3db13e83e827 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 17:44:35 +0000 Subject: [PATCH 08/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7434e58..847f4ae 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toArray = require( '@stdlib/ndarray-base-to-array' ); @@ -50,7 +50,7 @@ var toArray = require( '@stdlib/ndarray-base-to-array' ); */ function ndarray2array( arr ) { if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) ); + throw new TypeError( format( '1dfKy', arr ) ); } return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); } diff --git a/package.json b/package.json index 82cf131..5456523 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-ndarray-like": "^0.1.0", "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 6db4f32f17632fe3a85be4c1b7924185a2513eec Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:29:18 +0000 Subject: [PATCH 09/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 31c9d6d..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 2.0 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param arr - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( array: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 08194d5..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.0.2-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("invalid argument. Must provide an ndarray. Value: `%s`.",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 5871db4..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;oRAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index e0aba60..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c76522c960be6d3538f0698d866de8f1def204d0 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:31:04 +0000 Subject: [PATCH 10/58] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 62 - .github/workflows/cancel.yml | 56 - .github/workflows/close_pull_requests.yml | 44 - .github/workflows/examples.yml | 62 - .github/workflows/npm_downloads.yml | 108 - .github/workflows/productionize.yml | 783 --- .github/workflows/publish.yml | 242 - .github/workflows/test.yml | 97 - .github/workflows/test_bundles.yml | 180 - .github/workflows/test_coverage.yml | 123 - .github/workflows/test_install.yml | 83 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 61 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/test.js | 422 -- 41 files changed, 6205 insertions(+), 4148 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) create mode 100644 index.mjs create mode 100644 index.mjs.map delete mode 100644 lib/index.js delete mode 100644 lib/main.js create mode 100644 stats.html delete mode 100644 test/test.js diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 06a9a75..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index a00dbe5..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,56 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - uses: styfle/cancel-workflow-action@0.11.0 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index 8b42ff3..0000000 --- a/.github/workflows/close_pull_requests.yml +++ /dev/null @@ -1,44 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: close_pull_requests - -# Workflow triggers: -on: - pull_request_target: - types: [opened] - -# Workflow jobs: -jobs: - run: - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Thank you for submitting a pull request. :raised_hands: - - We greatly appreciate your willingness to submit a contribution. However, we are not accepting pull requests against this repository, as all development happens on the [main project repository](https://github.com/stdlib-js/stdlib). - - We kindly request that you submit this pull request against the [respective directory](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index 7902a7d..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,62 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout the repository' - uses: actions/checkout@v3 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index 3eb7ca5..0000000 --- a/.github/workflows/npm_downloads.yml +++ /dev/null @@ -1,108 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: npm_downloads - -# Workflow triggers: -on: - # Run this workflow weekly: - schedule: - # cron: ' ' - - cron: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - uses: actions/upload-artifact@v3 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - uses: distributhor/workflow-webhook@v3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 91f2b93..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,783 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - uses: actions/checkout@v3 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/checkout@v3 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - uses: act10ns/slack@v2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - uses: actions/checkout@v3 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - uses: actions/setup-node@v3 - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +175,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -242,7 +235,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c99a185..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(v,a){ -var s=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/error-tools-fmtprodmsg/dist'),u=require('@stdlib/ndarray-base-to-array/dist');function o(r){if(!s(r))throw new TypeError(n('1dfDv',r));return u(r.data,r.shape,r.strides,r.offset,r.order)}a.exports=o -});var d=t();module.exports=d; -/** @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 70ac8aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar format = require( '@stdlib/string-format' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,+BAAgC,EA0BvD,SAASC,EAAeC,EAAM,CAC7B,GAAK,CAACJ,EAAeI,CAAI,EACxB,MAAM,IAAI,UAAWH,EAAQ,0DAA2DG,CAAI,CAAE,EAE/F,OAAOF,EAASE,EAAI,KAAMA,EAAI,MAAOA,EAAI,QAASA,EAAI,OAAQA,EAAI,KAAM,CACzE,CAKAL,EAAO,QAAUI,IChBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "format", "toArray", "ndarray2array", "arr", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 2f13aa5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( arr ) - Converts an ndarray to a generic array. - - Parameters - ---------- - arr: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 7ed476b..1602a22 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..a7f9915 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("1dfKy",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2946458 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( '1dfKy', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;kSAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 847f4ae..0000000 --- a/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} arr - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( arr ) { - if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( '1dfKy', arr ) ); - } - return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 5456523..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-array-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.0.6", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -91,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b836b88 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9e4d063..0000000 --- a/test/test.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From eb6ffa9c2e9fb3d4d0c99be4eb328daa96a5d83c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:49:22 +0000 Subject: [PATCH 11/58] 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 234aa05..7021d77 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.1.0-esm/index.mjs'; ``` #### ndarray2array( arr ) @@ -106,7 +106,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.1.0-esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From e88e0f3cff19412d8d345ec430778cac1f0b924d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 24 Sep 2023 18:49:22 +0000 Subject: [PATCH 12/58] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7021d77..2a023fc 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@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-to-array/tags). For example, + ```javascript import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.1.0-esm/index.mjs'; ``` @@ -106,7 +111,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.1.0-esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From ef116fed3d4ef92b870e62e915fad924d86df59e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 1 Oct 2023 17:21:31 +0000 Subject: [PATCH 13/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7434e58..847f4ae 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toArray = require( '@stdlib/ndarray-base-to-array' ); @@ -50,7 +50,7 @@ var toArray = require( '@stdlib/ndarray-base-to-array' ); */ function ndarray2array( arr ) { if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) ); + throw new TypeError( format( '1dfKy', arr ) ); } return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); } diff --git a/package.json b/package.json index 0fe9978..64c2461 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-ndarray-like": "^0.1.0", "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/string-format": "^0.1.0", + "@stdlib/error-tools-fmtprodmsg": "^0.1.0", "@stdlib/types": "^0.1.0" }, "devDependencies": { From f950253e6775cc5fdf6b8bf11875fc6fe436c18b Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 03:06:16 +0000 Subject: [PATCH 14/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 1602a22..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param arr - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( array: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a7f9915..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("1dfKy",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2946458..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( '1dfKy', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;kSAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b836b88..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 073369cebd50c3182a8608e2515b360c017b8071 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Tue, 3 Oct 2023 03:10:07 +0000 Subject: [PATCH 15/58] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 61 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 422 -- test/test.js | 422 -- 43 files changed, 6205 insertions(+), 4629 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index c4d935a..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-10-01T05:38:02.960Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index bcf04be..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +175,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -242,7 +235,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c99a185..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(v,a){ -var s=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/error-tools-fmtprodmsg/dist'),u=require('@stdlib/ndarray-base-to-array/dist');function o(r){if(!s(r))throw new TypeError(n('1dfDv',r));return u(r.data,r.shape,r.strides,r.offset,r.order)}a.exports=o -});var d=t();module.exports=d; -/** @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 70ac8aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar format = require( '@stdlib/string-format' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,+BAAgC,EA0BvD,SAASC,EAAeC,EAAM,CAC7B,GAAK,CAACJ,EAAeI,CAAI,EACxB,MAAM,IAAI,UAAWH,EAAQ,0DAA2DG,CAAI,CAAE,EAE/F,OAAOF,EAASE,EAAI,KAAMA,EAAI,MAAOA,EAAI,QAASA,EAAI,OAAQA,EAAI,KAAM,CACzE,CAKAL,EAAO,QAAUI,IChBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "format", "toArray", "ndarray2array", "arr", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 2f13aa5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( arr ) - Converts an ndarray to a generic array. - - Parameters - ---------- - arr: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 7ed476b..1602a22 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..a7f9915 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("1dfKy",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2946458 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( '1dfKy', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;kSAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 847f4ae..0000000 --- a/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} arr - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( arr ) { - if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( '1dfKy', arr ) ); - } - return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 64c2461..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.0", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.0", - "@stdlib/assert-is-array-array": "^0.1.0", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.0", - "@stdlib/ndarray-base-shape2strides": "^0.1.0", - "@stdlib/ndarray-base-strides2offset": "^0.1.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -91,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..6159b32 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index c435409..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9e4d063..0000000 --- a/test/test.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From e1a72750bcc18a5abce7212c4a2d4c94fc3d65e8 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 5 Oct 2023 20:28:26 +0000 Subject: [PATCH 16/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 7434e58..847f4ae 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,7 +21,7 @@ // MODULES // var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); var toArray = require( '@stdlib/ndarray-base-to-array' ); @@ -50,7 +50,7 @@ var toArray = require( '@stdlib/ndarray-base-to-array' ); */ function ndarray2array( arr ) { if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) ); + throw new TypeError( format( '1dfKy', arr ) ); } return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); } diff --git a/package.json b/package.json index 6f2821d..7d3ded7 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "dependencies": { "@stdlib/assert-is-ndarray-like": "^0.1.0", "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From fed939b789f26b9e5a2344c0874f76f7b9f8a7c3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:52:08 +0000 Subject: [PATCH 17/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 1602a22..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param arr - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( array: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a7f9915..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("1dfKy",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2946458..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( '1dfKy', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;kSAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 6159b32..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 59d3ee7b190ceba1f17057299478d7608c5e33ed Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 7 Oct 2023 03:55:17 +0000 Subject: [PATCH 18/58] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 61 - package.json | 66 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 422 -- test/test.js | 422 -- 42 files changed, 6205 insertions(+), 4628 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index bcf04be..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +175,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -242,7 +235,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index c99a185..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(v,a){ -var s=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/error-tools-fmtprodmsg/dist'),u=require('@stdlib/ndarray-base-to-array/dist');function o(r){if(!s(r))throw new TypeError(n('1dfDv',r));return u(r.data,r.shape,r.strides,r.offset,r.order)}a.exports=o -});var d=t();module.exports=d; -/** @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 70ac8aa..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar format = require( '@stdlib/string-format' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAS,QAAS,uBAAwB,EAC1CC,EAAU,QAAS,+BAAgC,EA0BvD,SAASC,EAAeC,EAAM,CAC7B,GAAK,CAACJ,EAAeI,CAAI,EACxB,MAAM,IAAI,UAAWH,EAAQ,0DAA2DG,CAAI,CAAE,EAE/F,OAAOF,EAASE,EAAI,KAAMA,EAAI,MAAOA,EAAI,QAASA,EAAI,OAAQA,EAAI,KAAM,CACzE,CAKAL,EAAO,QAAUI,IChBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "format", "toArray", "ndarray2array", "arr", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index 2f13aa5..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( arr ) - Converts an ndarray to a generic array. - - Parameters - ---------- - arr: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 7ed476b..1602a22 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..9ee4ab8 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("1dfKy",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..2946458 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( '1dfKy', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;kSAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 847f4ae..0000000 --- a/lib/main.js +++ /dev/null @@ -1,61 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} arr - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( arr ) { - if ( !isndarrayLike( arr ) ) { - throw new TypeError( format( '1dfKy', arr ) ); - } - return toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order ); -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 7d3ded7..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,44 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.0", - "@stdlib/complex-realf": "^0.1.0", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -91,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..84160ed --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index c435409..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 9e4d063..0000000 --- a/test/test.js +++ /dev/null @@ -1,422 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 6ceb109fda73cef9e5b722a1f3312732e2077bd5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Oct 2023 01:55:20 +0000 Subject: [PATCH 19/58] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 53d1834..7579657 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "github:stdlib-js/ndarray-order#main", "@stdlib/ndarray-shape": "github:stdlib-js/ndarray-shape#main", "@stdlib/ndarray-strides": "github:stdlib-js/ndarray-strides#main", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From c48101b03b07870f747af65a2864b628c438ff98 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Oct 2023 01:55:52 +0000 Subject: [PATCH 20/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 1602a22..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param arr - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( array: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 9ee4ab8..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import r from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import s from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";function e(e){if(!r(e))throw new TypeError(s("1dfKy",e));return t(e.data,e.shape,e.strides,e.offset,e.order)}export{e as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 2946458..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport format from '@stdlib/error-tools-fmtprodmsg';\nimport toArray from '@stdlib/ndarray-base-to-array';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} arr - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( arr ) {\n\tif ( !isndarrayLike( arr ) ) {\n\t\tthrow new TypeError( format( '1dfKy', arr ) );\n\t}\n\treturn toArray( arr.data, arr.shape, arr.strides, arr.offset, arr.order );\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","arr","isndarrayLike","TypeError","format","toArray","data","shape","strides","offset","order"],"mappings":";;kSAkDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASJ,EAAIK,KAAML,EAAIM,MAAON,EAAIO,QAASP,EAAIQ,OAAQR,EAAIS,MACnE"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 84160ed..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 66aea497179e8fe4512d12fb4bce0495d250485f Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 12 Oct 2023 01:59:05 +0000 Subject: [PATCH 21/58] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 247 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 42 files changed, 6205 insertions(+), 4277 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index bcf04be..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +175,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -242,7 +235,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index eb10502..816b7d4 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..11e908a --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function a(a){if(!s(a))throw new TypeError(m("invalid argument. Must provide an ndarray. Value: `%s`.",a));return r(n(a),d(a),t(a),e(a),i(a))}export{a as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..b360e7a --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;urBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0b18283..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 7579657..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,49 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/ndarray-data-buffer": "github:stdlib-js/ndarray-data-buffer#main", - "@stdlib/ndarray-offset": "github:stdlib-js/ndarray-offset#main", - "@stdlib/ndarray-order": "github:stdlib-js/ndarray-order#main", - "@stdlib/ndarray-shape": "github:stdlib-js/ndarray-shape#main", - "@stdlib/ndarray-strides": "github:stdlib-js/ndarray-strides#main", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..b3fb8dc --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From cb76641b8b3252b6182511c83776b6688cd8d072 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Wed, 1 Nov 2023 18:13:44 +0000 Subject: [PATCH 22/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..30d8172 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfKy', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 3bad1fd..9d06140 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.1.0" }, "devDependencies": { From 4eab42bced8d1016420f1116185d0ec69c7f6910 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 03:07:39 +0000 Subject: [PATCH 23/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 816b7d4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 11e908a..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function a(a){if(!s(a))throw new TypeError(m("invalid argument. Must provide an ndarray. Value: `%s`.",a));return r(n(a),d(a),t(a),e(a),i(a))}export{a as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index b360e7a..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;urBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index b3fb8dc..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From d3b7b5ea23d12b71123f748d7e6a6d62f89b3c9c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 3 Nov 2023 03:10:20 +0000 Subject: [PATCH 24/58] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 47 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 43 files changed, 6205 insertions(+), 4286 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 70ee5ae..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-11-01T05:59:30.262Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index bcf04be..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -182,7 +175,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -242,7 +235,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/stdlib/tree/esm
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index eb10502..816b7d4 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..2f12276 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfKy",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a7ba8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfKy', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 30d8172..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfKy', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 9d06140..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,49 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/ndarray-data-buffer": "^0.1.0", - "@stdlib/ndarray-offset": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.1.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.1.0", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..a31e96b --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From b65cbb2e61dc4c20a5c0b1d851f20dc6ed07c486 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 13:31:21 +0000 Subject: [PATCH 25/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..30d8172 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfKy', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 8c90258..48705b5 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 304613910805fd2426afac968e28314b872c45d3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:21:14 +0000 Subject: [PATCH 26/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 816b7d4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f12276..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfKy",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a7ba8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfKy', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index a31e96b..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 6ecf7af46f2e60cc3871d43b09d61b25208e91ab Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 9 Nov 2023 17:24:07 +0000 Subject: [PATCH 27/58] Auto-generated commit --- .editorconfig | 186 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 42 files changed, 6206 insertions(+), 4286 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 13e9c39..0000000 --- a/.editorconfig +++ /dev/null @@ -1,186 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tslint.json` files: -[tslint.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index bcf04be..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index eb10502..816b7d4 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..2f12276 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfKy",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a7ba8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfKy', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 30d8172..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfKy', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 48705b5..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,49 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/ndarray-data-buffer": "^0.1.0", - "@stdlib/ndarray-offset": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.2.0", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..17f64e9 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 9d282391359897071c6762e1580c1ff45b25d231 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Dec 2023 14:22:46 +0000 Subject: [PATCH 28/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..30d8172 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfKy', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 39055d6..3d8a9a5 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From 49c4e77c386c7ee37537204228b0881431fec841 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:49:36 +0000 Subject: [PATCH 29/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 816b7d4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f12276..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfKy",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a7ba8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfKy', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 17f64e9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3f1f75b2f7fec060b78db9e58e614d66888fd9e5 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 2 Dec 2023 12:52:15 +0000 Subject: [PATCH 30/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 227 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 43 files changed, 6206 insertions(+), 4282 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 426e154..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-12-01T06:04:39.471Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index ab56cca..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c1c45e7..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index bcf04be..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA corresponding to v3.0.3: - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 265afda..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA corresponding to v4.1.0 - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 16 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index 61a7e50..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var bench = require( '@stdlib/bench' ); -var isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index eb10502..816b7d4 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..2f12276 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfKy",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..a7ba8b0 --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfKy', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 30d8172..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfKy', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 3d8a9a5..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,49 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/ndarray-data-buffer": "^0.1.0", - "@stdlib/ndarray-offset": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/bench": "^0.2.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7a84e19 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 7448462b50d6018b4dd82522163e97a1bef4ae87 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 08:38:03 +0000 Subject: [PATCH 31/58] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bf0053d..29b2f14 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.1.0", "@stdlib/ndarray-shape": "^0.1.0", "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/string-format": "^0.1.1", + "@stdlib/error-tools-fmtprodmsg": "^0.1.1", "@stdlib/types": "^0.2.0" }, "devDependencies": { From cef42e1e09f863ae88883d5c55b960701f67f0ae Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:12:46 +0000 Subject: [PATCH 32/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 816b7d4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 2f12276..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2023 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.1.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfKy",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index a7ba8b0..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfKy', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7a84e19..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From c4d45cb3e7673af21259d807fca94544fd4d5c8c Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jan 2024 15:13:24 +0000 Subject: [PATCH 33/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 128 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 49 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 53 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 44 files changed, 6206 insertions(+), 4288 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 4789357..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-01-01T05:34:18.506Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index 30656c4..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index 3acd3a9..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA corresponding to v0.11.0 - uses: styfle/cancel-workflow-action@b173b6ec0100793626c2d9e6b90435061f4fc3e5 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) of the main repository where we’ll review and provide feedback. If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. - - Thank you again, and we look forward to receiving your contribution! :smiley: - - Best, - The stdlib team \ No newline at end of file diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml deleted file mode 100644 index c92f5c4..0000000 --- a/.github/workflows/examples.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: examples - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run the package examples... - examples: - - # Define display name: - name: 'Run examples' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - - # Checkout repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run examples: - - name: 'Run examples' - run: | - npm run examples diff --git a/.github/workflows/npm_downloads.yml b/.github/workflows/npm_downloads.yml deleted file mode 100644 index dbdad40..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index e1e3539..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA corresponding to v3.8.1 - uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -189,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -249,11 +242,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index 5d16d3e..0000000 --- a/branches.md +++ /dev/null @@ -1,53 +0,0 @@ - - -# Branches - -This repository has the following branches: - -- **main**: default branch generated from the [stdlib project][stdlib-url], where all development takes place. -- **production**: [production build][production-url] of the package (e.g., reformatted error messages to reduce bundle sizes and thus the number of bytes transmitted over a network). -- **esm**: [ES Module][esm-url] branch for use via a `script` tag without the need for installation and bundlers. -- **deno**: [Deno][deno-url] branch for use in Deno. -- **umd**: [UMD][umd-url] branch for use in Observable, or in dual browser/Node.js environments. - -The following diagram illustrates the relationships among the above branches: - -```mermaid -graph TD; -A[stdlib]-->|generate standalone package|B; -B[main] -->|productionize| C[production]; -C -->|bundle| D[esm]; -C -->|bundle| E[deno]; -C -->|bundle| F[umd]; - -%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm \ No newline at end of file diff --git a/dist/index.d.ts b/dist/index.d.ts deleted file mode 100644 index e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index eb10502..816b7d4 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..de69571 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function a(a){if(!s(a))throw new TypeError(m("invalid argument. Must provide an ndarray. Value: `%s`.",a));return r(n(a),d(a),t(a),e(a),i(a))}export{a as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..560a8bd --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;0tBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0b18283..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 29b2f14..4e791a9 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.1.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,49 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.1.0", - "@stdlib/ndarray-base-to-array": "^0.1.0", - "@stdlib/ndarray-data-buffer": "^0.1.0", - "@stdlib/ndarray-offset": "^0.1.0", - "@stdlib/ndarray-order": "^0.1.0", - "@stdlib/ndarray-shape": "^0.1.0", - "@stdlib/ndarray-strides": "^0.1.0", - "@stdlib/error-tools-fmtprodmsg": "^0.1.1", - "@stdlib/types": "^0.2.0" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.1.1", - "@stdlib/assert-is-array-array": "^0.1.1", - "@stdlib/complex-imagf": "^0.1.1", - "@stdlib/complex-realf": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.1.1", - "@stdlib/ndarray-base-shape2strides": "^0.1.1", - "@stdlib/ndarray-base-strides2offset": "^0.1.1", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.1.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..f18c8f9 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 26660b3d941fdf4bf06c022481cbfada5d39dafc Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 01:25:13 +0000 Subject: [PATCH 34/58] Transform error messages --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8b735cb..e34dd35 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.2.0", "@stdlib/ndarray-shape": "^0.2.0", "@stdlib/ndarray-strides": "^0.2.0", - "@stdlib/string-format": "^0.2.0", + "@stdlib/error-tools-fmtprodmsg": "^0.2.0", "@stdlib/types": "^0.3.1" }, "devDependencies": { From bdced13a04e661a02ee1a98da37166e25651b322 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:54:58 +0000 Subject: [PATCH 35/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 816b7d4..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( `@stdlib/ndarray/array` ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index de69571..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.1.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.1.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.1.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.1.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.1.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.1.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function a(a){if(!s(a))throw new TypeError(m("invalid argument. Must provide an ndarray. Value: `%s`.",a));return r(n(a),d(a),t(a),e(a),i(a))}export{a as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 560a8bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;0tBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index f18c8f9..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 1b1e8e284b3222944af2e58b540aaad849b21dd3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 04:55:58 +0000 Subject: [PATCH 36/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 --- .github/workflows/publish.yml | 255 - .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 71 +- stats.html | 6177 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 43 files changed, 6206 insertions(+), 4296 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) 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 6d65557..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA corresponding to v3.1.3 - uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -191,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -254,11 +245,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index beca644..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/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 41e22a7..a5cf41c 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..b752309 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function a(a){if(!s(a))throw new TypeError(m("invalid argument. Must provide an ndarray. Value: `%s`.",a));return r(n(a),d(a),t(a),e(a),i(a))}export{a as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..560a8bd --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;0tBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 0b18283..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index e34dd35..bdf867b 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.0", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,49 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.2.0", - "@stdlib/ndarray-base-to-array": "^0.2.0", - "@stdlib/ndarray-data-buffer": "^0.2.0", - "@stdlib/ndarray-offset": "^0.2.0", - "@stdlib/ndarray-order": "^0.2.0", - "@stdlib/ndarray-shape": "^0.2.0", - "@stdlib/ndarray-strides": "^0.2.0", - "@stdlib/error-tools-fmtprodmsg": "^0.2.0", - "@stdlib/types": "^0.3.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.1.0", - "@stdlib/array-complex64": "^0.1.0", - "@stdlib/assert-is-array": "^0.2.0", - "@stdlib/assert-is-array-array": "^0.2.0", - "@stdlib/complex-imagf": "^0.2.0", - "@stdlib/complex-realf": "^0.2.0", - "@stdlib/ndarray-base-numel": "^0.2.0", - "@stdlib/ndarray-base-shape2strides": "^0.2.0", - "@stdlib/ndarray-base-strides2offset": "^0.2.0", - "@stdlib/ndarray-ctor": "^0.1.0", - "@stdlib/random-base-discrete-uniform": "^0.1.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -96,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..fba8608 --- /dev/null +++ b/stats.html @@ -0,0 +1,6177 @@ + + + + + + + + Rollup Visualizer + + + +
+ + + + + diff --git a/test/dist/test.js b/test/dist/test.js deleted file mode 100644 index a8a9c60..0000000 --- a/test/dist/test.js +++ /dev/null @@ -1,33 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var tape = require( 'tape' ); -var main = require( './../../dist' ); - - -// TESTS // - -tape( 'main export is defined', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( main !== void 0, true, 'main export is defined' ); - t.end(); -}); diff --git a/test/test.js b/test/test.js deleted file mode 100644 index 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 0f6505eca0ff12139427ddbb6a0c509c9105d326 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:45 +0000 Subject: [PATCH 37/58] Update README.md for ESM bundle v0.2.0 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82ba0c1..99763be 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.0-esm/index.mjs'; ``` #### ndarray2array( x ) @@ -106,7 +106,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.0-esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From 47afac48bac8dc8e3a2daaf0f04bad422adc7299 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Thu, 15 Feb 2024 06:38:46 +0000 Subject: [PATCH 38/58] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99763be..2274d8f 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@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-to-array/tags). For example, + ```javascript import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.0-esm/index.mjs'; ``` @@ -106,7 +111,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.0-esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From cab8d38f483a8997f4271ffc5e6690bdd3365cee Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 20:06:28 +0000 Subject: [PATCH 39/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..6958225 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfDv', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 6918f4e..d7211bb 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 781c4e4405846c0b5ed8b046454c73be6a7af1bd Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:26:13 +0000 Subject: [PATCH 40/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 6177 ------------------------------------------------- 4 files changed, 6225 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 a5cf41c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index b752309..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.0-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.1.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.0-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.0-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.0-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.0-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.0-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/string-format@v0.1.1-esm/index.mjs";function a(a){if(!s(a))throw new TypeError(m("invalid argument. Must provide an ndarray. Value: `%s`.",a));return r(n(a),d(a),t(a),e(a),i(a))}export{a as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 560a8bd..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/string-format';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;0tBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,0DAA2DH,IAEzF,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index fba8608..0000000 --- a/stats.html +++ /dev/null @@ -1,6177 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 3a91a5a23beefee9a18d058dd439383e0f700c6a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 21:26:39 +0000 Subject: [PATCH 41/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 228 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 43 files changed, 4871 insertions(+), 4291 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) 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 5ab7164..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -191,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -254,11 +245,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index beca644..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/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 41e22a7..a5cf41c 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..a013504 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..05c2dea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6958225..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfDv', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index d7211bb..7ae6df8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,50 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/ndarray-base-to-array": "^0.2.1", - "@stdlib/ndarray-data-buffer": "^0.2.1", - "@stdlib/ndarray-offset": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.0", - "@stdlib/array-complex64": "^0.2.0", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.0", - "@stdlib/random-base-discrete-uniform": "^0.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -97,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..3d306e5 --- /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 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From e2b4c2968a6359534efaf95b96a01348a98f2807 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:05:57 +0000 Subject: [PATCH 42/58] Update README.md for ESM bundle v0.2.1 --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 44e79cc..a02aa1e 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ limitations under the License. ## Usage ```javascript -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.1-esm/index.mjs'; ``` #### ndarray2array( x ) @@ -106,7 +106,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.1-esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From c58216c77bf91cbef7b504a39b7f006091dd5b64 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sun, 25 Feb 2024 22:05:58 +0000 Subject: [PATCH 43/58] Auto-generated commit --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a02aa1e..e074da7 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,11 @@ limitations under the License. ## Usage +```javascript +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@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-to-array/tags). For example, + ```javascript import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.1-esm/index.mjs'; ``` @@ -106,7 +111,7 @@ import strides2offset from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-s import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-base-discrete-uniform@esm/index.mjs'; import zeroTo from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-base-zero-to@esm/index.mjs'; import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ctor@esm/index.mjs'; -import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@v0.2.1-esm/index.mjs'; +import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs'; // Create a data buffer: var buffer = zeroTo( 27 ); From d42cd9f9266fb098640e3c510e5f9752bc61c272 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 08:28:58 +0000 Subject: [PATCH 44/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..6958225 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfDv', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index a69e3f6..de263cf 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 506fb5b3a62a225b3412c8c9cc84530dc436fe57 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:16:25 +0000 Subject: [PATCH 45/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 a5cf41c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index a013504..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.0-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 05c2dea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 3d306e5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 19e701e9f26da3b37706e88aa7150854fe89dab3 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 1 Mar 2024 14:16:47 +0000 Subject: [PATCH 46/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 28 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 44 files changed, 4871 insertions(+), 4293 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 18fe1ea..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-03-01T06:07:12.100Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) 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 5ab7164..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index 9106b5d..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA corresponding to v2.0.0 - uses: act10ns/slack@ed1309ab9862e57e9e583e51c7889486b9a00b0f - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -191,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -254,11 +245,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index beca644..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/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 41e22a7..a5cf41c 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..3b10578 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..05c2dea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6958225..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfDv', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index de263cf..7ae6df8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,50 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/ndarray-base-to-array": "^0.2.1", - "@stdlib/ndarray-data-buffer": "^0.2.1", - "@stdlib/ndarray-offset": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -97,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1aefdff --- /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 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From c082df1758d19b19acba18531598d190b2177c37 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 07:45:18 +0000 Subject: [PATCH 47/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..6958225 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfDv', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index a69e3f6..de263cf 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 1f189f916d2c642e41c359267a60a49e00a69891 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:14:47 +0000 Subject: [PATCH 48/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 a5cf41c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3b10578..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 05c2dea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1aefdff..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From aae9762fa51c73454ce2d296ef69449a64be2735 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Apr 2024 13:15:11 +0000 Subject: [PATCH 49/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 132 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 44 files changed, 4871 insertions(+), 4296 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/.keepalive delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index d0aabe0..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2024-04-01T05:22:55.943Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) 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 5ab7164..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -191,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -254,11 +245,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index beca644..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/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 41e22a7..a5cf41c 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..3b10578 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..05c2dea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6958225..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfDv', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index de263cf..7ae6df8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,50 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/ndarray-base-to-array": "^0.2.1", - "@stdlib/ndarray-data-buffer": "^0.2.1", - "@stdlib/ndarray-offset": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -97,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1aefdff --- /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 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 091fe1fc42d17de1dcc46f0a30ae037c7e177c5e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 03:58:35 +0000 Subject: [PATCH 50/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..6958225 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfDv', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index a69e3f6..de263cf 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.2.1", "@stdlib/ndarray-shape": "^0.2.1", "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/string-format": "^0.2.1", + "@stdlib/error-tools-fmtprodmsg": "^0.2.1", "@stdlib/types": "^0.3.2", "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, From 090e56870fa2a3fd5a912ff12c45045dba45f720 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:25:56 +0000 Subject: [PATCH 51/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 a5cf41c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3b10578..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 05c2dea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1aefdff..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 2325796e8f777a516374aa4df61404196e6c6e78 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 12 Apr 2024 09:26:14 +0000 Subject: [PATCH 52/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 49 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 797 ---- .github/workflows/publish.yml | 249 -- .github/workflows/test.yml | 100 - .github/workflows/test_bundles.yml | 189 - .github/workflows/test_coverage.yml | 134 - .github/workflows/test_install.yml | 86 - .gitignore | 188 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 5 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 --- README.md | 51 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 72 +- stats.html | 4842 +++++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 43 files changed, 4871 insertions(+), 4297 deletions(-) delete mode 100644 .editorconfig delete mode 100644 .eslintrc.js delete mode 100644 .gitattributes delete mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 .github/workflows/benchmark.yml delete mode 100644 .github/workflows/cancel.yml delete mode 100644 .github/workflows/close_pull_requests.yml delete mode 100644 .github/workflows/examples.yml delete mode 100644 .github/workflows/npm_downloads.yml delete mode 100644 .github/workflows/productionize.yml delete mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/test.yml delete mode 100644 .github/workflows/test_bundles.yml delete mode 100644 .github/workflows/test_coverage.yml delete mode 100644 .github/workflows/test_install.yml delete mode 100644 .gitignore delete mode 100644 .npmignore delete mode 100644 .npmrc delete mode 100644 CHANGELOG.md delete mode 100644 CITATION.cff delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 CONTRIBUTING.md delete mode 100644 Makefile delete mode 100644 SECURITY.md delete mode 100644 benchmark/benchmark.js delete mode 100644 benchmark/python/numpy/benchmark.py 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 (93%) 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 60d743f..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = false - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 10a16e6..0000000 --- a/.gitattributes +++ /dev/null @@ -1,49 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/deps/** linguist-vendored=false -/lib/node_modules/** linguist-vendored=false linguist-generated=false -test/fixtures/** linguist-vendored=false -tools/** linguist-vendored=false - -# Override what is considered "documentation" by GitHub's linguist: -examples/** linguist-documentation=false diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) 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 5ab7164..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: '10 10 * * 0' - - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job for retrieving npm download counts... - npm_downloads: - - # Define display name: - name: 'Retrieve npm download counts' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - timeout-minutes: 10 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Resolve package name: - - name: 'Resolve package name' - id: package_name - run: | - name=`node -e 'console.log(require("./package.json").name)' | tr -d '\n'` - echo "package_name=$name" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Fetch download data: - - name: 'Fetch data' - id: download_data - run: | - url="https://api.npmjs.org/downloads/range/$(date --date='1 year ago' '+%Y-%m-%d'):$(date '+%Y-%m-%d')/${{ steps.package_name.outputs.package_name }}" - echo "$url" - data=$(curl "$url") - mkdir ./tmp - echo "$data" > ./tmp/npm_downloads.json - echo "data=$data" >> $GITHUB_OUTPUT - timeout-minutes: 5 - - # Print summary of download data: - - name: 'Print summary' - run: | - echo "| Date | Downloads |" >> $GITHUB_STEP_SUMMARY - echo "|------|------------|" >> $GITHUB_STEP_SUMMARY - cat ./tmp/npm_downloads.json | jq -r ".downloads | .[-14:] | to_entries | map(\"| \(.value.day) | \(.value.downloads) |\") |.[]" >> $GITHUB_STEP_SUMMARY - - # Upload the download data: - - name: 'Upload data' - # Pin action to full length commit SHA - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 - with: - # Define a name for the uploaded artifact (ensuring a unique name for each job): - name: npm_downloads - - # Specify the path to the file to upload: - path: ./tmp/npm_downloads.json - - # Specify the number of days to retain the artifact (default is 90 days): - retention-days: 90 - timeout-minutes: 10 - if: success() - - # Send data to events server: - - name: 'Post data' - # Pin action to full length commit SHA - uses: distributhor/workflow-webhook@48a40b380ce4593b6a6676528cd005986ae56629 # v3.0.3 - env: - webhook_url: ${{ secrets.STDLIB_NPM_DOWNLOADS_URL }} - webhook_secret: ${{ secrets.STDLIB_WEBHOOK_SECRET }} - data: '{ "downloads": ${{ steps.download_data.outputs.data }} }' - timeout-minutes: 5 - if: success() diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml deleted file mode 100644 index ec90164..0000000 --- a/.github/workflows/productionize.yml +++ /dev/null @@ -1,797 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2022 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: productionize - -# Workflow triggers: -on: - # Run workflow when a new commit is pushed to the main branch: - push: - branches: - - main - - # Allow the workflow to be manually run: - workflow_dispatch: - inputs: - require-passing-tests: - description: 'Require passing tests for creating bundles' - type: boolean - default: true - - # Run workflow upon completion of `publish` workflow run: - workflow_run: - workflows: ["publish"] - types: [completed] - - -# Concurrency group to prevent multiple concurrent executions: -concurrency: - group: productionize - cancel-in-progress: true - -# Workflow jobs: -jobs: - - # Define a job to create a production build... - productionize: - - # Define display name: - name: 'Productionize' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - # Checkout main branch of repository: - - name: 'Checkout main branch' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - ref: main - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Create production branch: - - name: 'Create production branch' - run: | - git checkout -b production - - # Transform error messages: - - name: 'Transform error messages' - id: transform-error-messages - uses: stdlib-js/transform-errors-action@main - - # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - - name: 'Update dependencies in package.json' - run: | - PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) - if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json - else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" - fi - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Transform error messages" - - # Push changes: - - name: 'Push changes' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" production --force - - # Define a job for running tests of the productionized code... - test: - - # Define a display name: - name: 'Run Tests' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Indicate that this job depends on the prior job finishing: - needs: productionize - - # Run this job regardless of the outcome of the prior job: - if: always() - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - with: - # Use the `production` branch: - ref: production - - # Install Node.js: - - name: 'Install Node.js' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Build native add-on if present: - - name: 'Build native add-on (if present)' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - run: | - if [ -f "binding.gyp" ]; then - npm install node-gyp --no-save && ./node_modules/.bin/node-gyp rebuild - fi - - # Run tests: - - name: 'Run tests' - if: ${{ github.event.inputs.require-passing-tests == 'true' }} - id: tests - run: | - npm test || npm test || npm test - - # Define job to create a bundle for use in Deno... - deno: - - # Define display name: - name: 'Create Deno bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `deno` branch exists: - - name: 'Check if remote `deno` branch exists' - id: deno-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin deno - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `deno` exists, delete everything in branch and merge `production` into it - - name: 'If `deno` exists, delete everything in branch and merge `production` into it' - if: steps.deno-branch-exists.outputs.remote-exists - run: | - git checkout -b deno origin/deno - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `deno` does not exist, create `deno` branch: - - name: 'If `deno` does not exist, create `deno` branch' - if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b deno - - # Copy files to deno directory: - - name: 'Copy files to deno directory' - run: | - mkdir -p deno - cp README.md LICENSE CONTRIBUTORS NOTICE ./deno - - # Copy TypeScript definitions to deno directory: - if [ -d index.d.ts ]; then - cp index.d.ts ./deno/index.d.ts - fi - if [ -e ./docs/types/index.d.ts ]; then - cp ./docs/types/index.d.ts ./deno/mod.d.ts - fi - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: Install production and development dependencies - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Bundle package for use in Deno: - - name: 'Bundle package for Deno' - id: deno-bundle - uses: stdlib-js/bundle-action@main - with: - target: 'deno' - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - # Replace links to other packages with links to the deno branch: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/deno/"; - - # Replace reference to `@stdlib/types` with CDN link: - find ./deno -type f -name '*.ts' -print0 | xargs -0 -r sed -Ei "s/\/\/\/ /\/\/\/ /g" - - # Change wording of project description to avoid reference to JavaScript and Node.js: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/a standard library for JavaScript and Node.js, /a standard library /g" - - # Rewrite all `require()`s to use jsDelivr links: - find ./deno -type f -name '*.md' -print0 | xargs -0 sed -Ei "/require\( '@stdlib\// { - s/(var|let|const)\s+([a-z0-9_]+)\s+=\s*require\( '([^']+)' \);/import \2 from \'\3\';/i - s/@stdlib/https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js/ - s/';/@deno\/mod.js';/ - }" - - # Rewrite first `import` to show importing of named exports if available: - exports=$(cat lib/index.js | \ - grep -E 'setReadOnly\(.*,.*,.*\)' | \ - sed -E 's/setReadOnly\((.*),(.*),(.*)\);/\2/' | \ - sed -E "s/'//g" | \ - sort) - if [ -n "$exports" ]; then - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\nimport\s+([a-zA-Z0-9_]+)\s+from\s*'([^']+)';\n\`\`\`/\`\`\`javascript\nimport \1 from '\2';\n\`\`\`\n\nYou can also import the following named exports from the package:\n\n\`\`\`javascript\nimport { $(echo $exports | sed -E 's/ /, /g') } from '\2';\n\`\`\`/" - fi - - # Remove `installation`, `cli`, and `c` sections: - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./deno -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Create package.json file for deno branch: - jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json - - # Delete everything in current directory aside from deno folder: - - name: 'Delete everything in current directory aside from deno folder' - run: | - find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs -r rm -rf - - # Move deno directory to root: - - name: 'Move deno directory to root' - run: | - mv ./deno/* . - rmdir ./deno - - # Commit changes: - - name: 'Commit changes' - run: | - git add -A - git commit -m "Auto-generated commit" - - # Push changes to `deno` branch: - - name: 'Push changes to `deno` branch' - run: | - SLUG=${{ github.repository }} - echo "Pushing changes to $SLUG..." - git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" deno - - # Send status to Slack channel if job fails: - - name: 'Send status to Slack channel in case of failure' - # Pin action to full length commit SHA - uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2 - with: - status: ${{ job.status }} - steps: ${{ toJson(steps) }} - channel: '#npm-ci' - if: failure() - - # Define job to create a UMD bundle... - umd: - - # Define display name: - name: 'Create UMD bundle' - - # Define the type of virtual host machine on which to run the job: - runs-on: ubuntu-latest - - # Indicate that this job depends on the test job finishing: - needs: test - - # Define the sequence of job steps... - steps: - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Configure git: - - name: 'Configure git' - run: | - git config --local user.email "noreply@stdlib.io" - git config --local user.name "stdlib-bot" - - # Check if remote `umd` branch exists: - - name: 'Check if remote `umd` branch exists' - id: umd-branch-exists - continue-on-error: true - run: | - git fetch --all - git ls-remote --exit-code --heads origin umd - if [ $? -eq 0 ]; then - echo "remote-exists=true" >> $GITHUB_OUTPUT - else - echo "remote-exists=false" >> $GITHUB_OUTPUT - fi - - # If `umd` exists, delete everything in branch and merge `production` into it - - name: 'If `umd` exists, delete everything in branch and merge `production` into it' - if: steps.umd-branch-exists.outputs.remote-exists - run: | - git checkout -b umd origin/umd - - find . -type 'f' | grep -v -e ".git/" -e "package.json" -e "README.md" -e "LICENSE" -e "CONTRIBUTORS" -e "NOTICE" | xargs -r rm - find . -mindepth 1 -type 'd' | grep -v -e ".git" | xargs -r rm -rf - - git add -A - git commit -m "Remove files" --allow-empty - - git config merge.theirs.name 'simulate `-s theirs`' - git config merge.theirs.driver 'cat %B > %A' - GIT_CONFIG_PARAMETERS="'merge.default=theirs'" git merge origin/production --allow-unrelated-histories - - # Copy files from `production` branch if necessary: - git checkout origin/production -- . - if [ -n "$(git status --porcelain)" ]; then - git add -A - git commit -m "Auto-generated commit" - fi - - # If `umd` does not exist, create `umd` branch: - - name: 'If `umd` does not exist, create `umd` branch' - if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }} - run: | - git checkout production - git checkout -b umd - - # Copy files to umd directory: - - name: 'Copy files to umd directory' - run: | - mkdir -p umd - cp README.md LICENSE CONTRIBUTORS NOTICE ./umd - - # Install Node.js - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - id: install - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Extract alias: - - name: 'Extract alias' - id: extract-alias - run: | - alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/') - echo "alias=${alias}" >> $GITHUB_OUTPUT - - # Create Universal Module Definition (UMD) Node.js bundle: - - name: 'Create Universal Module Definition (UMD) Node.js bundle' - id: umd-bundle-node - uses: stdlib-js/bundle-action@main - with: - target: 'umd-node' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Create Universal Module Definition (UMD) browser bundle: - - name: 'Create Universal Module Definition (UMD) browser bundle' - id: umd-bundle-browser - uses: stdlib-js/bundle-action@main - with: - target: 'umd-browser' - alias: ${{ steps.extract-alias.outputs.alias }} - - # Rewrite file contents: - - name: 'Rewrite file contents' - run: | - - # Replace links to other packages with links to the umd branch: - find ./umd -type f -name '*.md' -print0 | xargs -0 sed -Ei "/\/tree\/main/b; /^\[@stdlib[^:]+: https:\/\/github.com\/stdlib-js\// s/(.*)/\\1\/tree\/umd/"; - - # Remove `installation`, `cli`, and `c` sections: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
[^<]+<\/section>//g;" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.cli \-\->//g" - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+<\!\-\- \/.c \-\->//g" - - # Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag: - find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo vendor stdlib functionality and avoid installing dependency trees for Node.js, you can use the UMD server build:\n\n\`\`\`javascript\nvar \2 = require\( 'path\/to\/vendor\/umd\/\3\/index.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n + + ```
@@ -191,7 +182,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -254,11 +245,11 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index beca644..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/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 41e22a7..a5cf41c 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..3b10578 --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..05c2dea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6958225..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfDv', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index de263cf..7ae6df8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,50 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.2.1", - "@stdlib/ndarray-base-to-array": "^0.2.1", - "@stdlib/ndarray-data-buffer": "^0.2.1", - "@stdlib/ndarray-offset": "^0.2.1", - "@stdlib/ndarray-order": "^0.2.1", - "@stdlib/ndarray-shape": "^0.2.1", - "@stdlib/ndarray-strides": "^0.2.1", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1", - "@stdlib/types": "^0.3.2", - "@stdlib/error-tools-fmtprodmsg": "^0.2.1" - }, - "devDependencies": { - "@stdlib/array-base-zero-to": "^0.2.1", - "@stdlib/array-complex64": "^0.2.1", - "@stdlib/assert-is-array": "^0.2.1", - "@stdlib/assert-is-array-array": "^0.2.1", - "@stdlib/complex-imagf": "^0.2.1", - "@stdlib/complex-realf": "^0.2.1", - "@stdlib/ndarray-base-numel": "^0.2.1", - "@stdlib/ndarray-base-shape2strides": "^0.2.1", - "@stdlib/ndarray-base-strides2offset": "^0.2.1", - "@stdlib/ndarray-ctor": "^0.2.1", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.1" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -97,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..1aefdff --- /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 67f454d..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-realf' ); -var imagf = require( '@stdlib/complex-imagf' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 70fcde8c0a67d3b51c7b71c6f7c1eafb4520508d Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Dec 2024 04:00:14 +0000 Subject: [PATCH 53/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..6958225 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfDv', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 8124664..339e8b2 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/ndarray-strides": "^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 ebd0d53582525bcb06e7189aa20b6e143e43a56a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Dec 2024 04:09:24 +0000 Subject: [PATCH 54/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 a5cf41c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 3b10578..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.1-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.1-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.1-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.1-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.1-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.1-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.1-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 05c2dea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 1aefdff..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 5c4cbe9a4f27455fd0b9301479e02a2f93a5563e Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Sat, 28 Dec 2024 04:09:58 +0000 Subject: [PATCH 55/58] Auto-generated commit --- .editorconfig | 181 - .eslintrc.js | 1 - .gitattributes | 66 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 190 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 188 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 44 files changed, 4872 insertions(+), 4599 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 benchmark/python/numpy/benchmark.py 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 (93%) 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 0779e8a..0000000 --- a/.editorconfig +++ /dev/null @@ -1,181 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# EditorConfig configuration file (see ). - -# Indicate that this file is a root-level configuration file: -root = true - -# Set properties for all files: -[*] -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -# Set properties for JavaScript files: -[*.{js,js.txt}] -indent_style = tab - -# Set properties for JavaScript ES module files: -[*.{mjs,mjs.txt}] -indent_style = tab - -# Set properties for JavaScript CommonJS files: -[*.{cjs,cjs.txt}] -indent_style = tab - -# Set properties for JSON files: -[*.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `cli_opts.json` files: -[cli_opts.json] -indent_style = tab - -# Set properties for TypeScript files: -[*.ts] -indent_style = tab - -# Set properties for Python files: -[*.{py,py.txt}] -indent_style = space -indent_size = 4 - -# Set properties for Julia files: -[*.{jl,jl.txt}] -indent_style = tab - -# Set properties for R files: -[*.{R,R.txt}] -indent_style = tab - -# Set properties for C files: -[*.{c,c.txt}] -indent_style = tab - -# Set properties for C header files: -[*.{h,h.txt}] -indent_style = tab - -# Set properties for C++ files: -[*.{cpp,cpp.txt}] -indent_style = tab - -# Set properties for C++ header files: -[*.{hpp,hpp.txt}] -indent_style = tab - -# Set properties for Fortran files: -[*.{f,f.txt}] -indent_style = space -indent_size = 2 -insert_final_newline = false - -# Set properties for shell files: -[*.{sh,sh.txt}] -indent_style = tab - -# Set properties for AWK files: -[*.{awk,awk.txt}] -indent_style = tab - -# Set properties for HTML files: -[*.{html,html.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for XML files: -[*.{xml,xml.txt}] -indent_style = tab -tab_width = 2 - -# Set properties for CSS files: -[*.{css,css.txt}] -indent_style = tab - -# Set properties for Makefiles: -[Makefile] -indent_style = tab - -[*.{mk,mk.txt}] -indent_style = tab - -# Set properties for Markdown files: -[*.{md,md.txt}] -indent_style = space -indent_size = 4 -trim_trailing_whitespace = true # Note: this disables using two spaces to force a hard line break, which is permitted in Markdown. As we don't typically follow that practice (TMK), we should be safe to automatically trim. - -# Set properties for `usage.txt` files: -[usage.txt] -indent_style = space -indent_size = 2 - -# Set properties for `repl.txt` files: -[repl.txt] -indent_style = space -indent_size = 4 - -# Set properties for `package.json` files: -[package.{json,json.txt}] -indent_style = space -indent_size = 2 - -# Set properties for `datapackage.json` files: -[datapackage.json] -indent_style = space -indent_size = 2 - -# Set properties for `manifest.json` files: -[manifest.json] -indent_style = space -indent_size = 2 - -# Set properties for `tsconfig.json` files: -[tsconfig.json] -indent_style = space -indent_size = 2 - -# Set properties for LaTeX files: -[*.{tex,tex.txt}] -indent_style = tab - -# Set properties for LaTeX Bibliography files: -[*.{bib,bib.txt}] -indent_style = tab - -# Set properties for YAML files: -[*.{yml,yml.txt}] -indent_style = space -indent_size = 2 - -# Set properties for GYP files: -[binding.gyp] -indent_style = space -indent_size = 2 - -[*.gypi] -indent_style = space -indent_size = 2 - -# Set properties for citation files: -[*.{cff,cff.txt}] -indent_style = space -indent_size = 2 diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index 5f30286..0000000 --- a/.eslintrc.js +++ /dev/null @@ -1 +0,0 @@ -/* For the `eslint` rules of this project, consult the main repository at https://github.com/stdlib-js/stdlib */ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1c88e69..0000000 --- a/.gitattributes +++ /dev/null @@ -1,66 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2017 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Configuration file which assigns attributes to pathnames. -# -# [1]: https://git-scm.com/docs/gitattributes - -# Automatically normalize the line endings of any committed text files: -* text=auto - -# Override line endings for certain files on checkout: -*.crlf.csv text eol=crlf - -# Denote that certain files are binary and should not be modified: -*.png binary -*.jpg binary -*.jpeg binary -*.gif binary -*.ico binary -*.gz binary -*.zip binary -*.7z binary -*.mp3 binary -*.mp4 binary -*.mov binary - -# Override what is considered "vendored" by GitHub's linguist: -/lib/node_modules/** -linguist-vendored -linguist-generated - -# Configure directories which should *not* be included in GitHub language statistics: -/deps/** linguist-vendored -/dist/** linguist-generated -/workshops/** linguist-vendored - -benchmark/** linguist-vendored -docs/* linguist-documentation -etc/** linguist-vendored -examples/** linguist-documentation -scripts/** linguist-vendored -test/** linguist-vendored -tools/** linguist-vendored - -# Configure files which should *not* be included in GitHub language statistics: -Makefile linguist-vendored -*.mk linguist-vendored -*.jl linguist-vendored -*.py linguist-vendored -*.R linguist-vendored - -# Configure files which should be included in GitHub language statistics: -docs/types/*.d.ts -linguist-documentation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 8dae607..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/to-array) of the main repository where we’ll review and provide feedback. - -If this is your first stdlib contribution, be sure to read the [contributing guide](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md) which provides guidelines and instructions for submitting contributions. You may also consult the [development guide](https://github.com/stdlib-js/stdlib/blob/develop/docs/development.md) for help on developing stdlib. - -We look forward to receiving your contribution! :smiley: \ No newline at end of file diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml deleted file mode 100644 index e4f10fe..0000000 --- a/.github/workflows/benchmark.yml +++ /dev/null @@ -1,64 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: benchmark - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to run benchmarks: - benchmark: - - # Define a display name: - name: 'Run benchmarks' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Define the sequence of job steps... - steps: - - # Checkout the repository: - - name: 'Checkout repository' - # Pin action to full length commit SHA - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 - - # Install Node.js: - - name: 'Install Node.js' - # Pin action to full length commit SHA - uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 - with: - node-version: 20 - timeout-minutes: 5 - - # Install dependencies: - - name: 'Install production and development dependencies' - run: | - npm install || npm install || npm install - timeout-minutes: 15 - - # Run benchmarks: - - name: 'Run benchmarks' - run: | - npm run benchmark diff --git a/.github/workflows/cancel.yml b/.github/workflows/cancel.yml deleted file mode 100644 index b5291db..0000000 --- a/.github/workflows/cancel.yml +++ /dev/null @@ -1,57 +0,0 @@ -#/ -# @license Apache-2.0 -# -# Copyright (c) 2021 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -#/ - -# Workflow name: -name: cancel - -# Workflow triggers: -on: - # Allow the workflow to be manually run: - workflow_dispatch: - -# Workflow jobs: -jobs: - - # Define a job to cancel existing workflow runs: - cancel: - - # Define a display name: - name: 'Cancel workflow runs' - - # Define the type of virtual host machine: - runs-on: 'ubuntu-latest' - - # Time limit: - timeout-minutes: 3 - - # Define the sequence of job steps... - steps: - - # Cancel existing workflow runs: - - name: 'Cancel existing workflow runs' - # Pin action to full length commit SHA - uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # v0.12.1 - with: - workflow_id: >- - benchmark.yml, - examples.yml, - test.yml, - test_coverage.yml, - test_install.yml, - publish.yml - access_token: ${{ github.token }} diff --git a/.github/workflows/close_pull_requests.yml b/.github/workflows/close_pull_requests.yml deleted file mode 100644 index bea7e4a..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/to-array) 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 5ab7164..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: '10 10 * * 0' - - # 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 + + ```
@@ -192,7 +183,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -255,13 +246,13 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/to-json]: https://github.com/stdlib-js/ndarray-to-json +[@stdlib/ndarray/to-json]: https://github.com/stdlib-js/ndarray-to-json/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index beca644..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/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 41e22a7..a5cf41c 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..1d0bbcb --- /dev/null +++ b/index.mjs @@ -0,0 +1,4 @@ +// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 +/// +import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..05c2dea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6958225..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfDv', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 339e8b2..7ae6df8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,50 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-base-to-array": "^0.2.1", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-offset": "^0.2.2", - "@stdlib/ndarray-order": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/ndarray-strides": "^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/array-complex64": "^0.3.0", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-array-array": "^0.2.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -97,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7302bb5 --- /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 696995f..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); From 1a364846d86c14228085197bc8015349a7a16570 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 00:52:41 +0000 Subject: [PATCH 56/58] Transform error messages --- lib/main.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/main.js b/lib/main.js index 0b18283..6958225 100644 --- a/lib/main.js +++ b/lib/main.js @@ -27,7 +27,7 @@ var getOffset = require( '@stdlib/ndarray-offset' ); var getShape = require( '@stdlib/ndarray-shape' ); var getOrder = require( '@stdlib/ndarray-order' ); var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/string-format' ); +var format = require( '@stdlib/error-tools-fmtprodmsg' ); // MAIN // @@ -55,7 +55,7 @@ var format = require( '@stdlib/string-format' ); */ function ndarray2array( x ) { if ( !isndarrayLike( x ) ) { - throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) ); + throw new TypeError( format( '1dfDv', x ) ); } return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len } diff --git a/package.json b/package.json index 8124664..339e8b2 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@stdlib/ndarray-order": "^0.2.2", "@stdlib/ndarray-shape": "^0.2.2", "@stdlib/ndarray-strides": "^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 519d315a50871aa8fc97414cfed34a0347d492d4 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:01:18 +0000 Subject: [PATCH 57/58] Remove files --- index.d.ts | 43 - index.mjs | 4 - index.mjs.map | 1 - stats.html | 4842 ------------------------------------------------- 4 files changed, 4890 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 a5cf41c..0000000 --- a/index.d.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -// TypeScript Version: 4.1 - -/// - -import { ndarray } from '@stdlib/types/ndarray'; - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param x - input ndarray -* @returns array (which may include nested arrays) -* -* @example -* var array = require( '@stdlib/ndarray-array' ); -* -* var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -declare function ndarray2array( x: ndarray ): Array; - - -// EXPORTS // - -export = ndarray2array; diff --git a/index.mjs b/index.mjs deleted file mode 100644 index 1d0bbcb..0000000 --- a/index.mjs +++ /dev/null @@ -1,4 +0,0 @@ -// Copyright (c) 2024 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 -/// -import s from"https://cdn.jsdelivr.net/gh/stdlib-js/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; -//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map deleted file mode 100644 index 05c2dea..0000000 --- a/index.mjs.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/stats.html b/stats.html deleted file mode 100644 index 7302bb5..0000000 --- a/stats.html +++ /dev/null @@ -1,4842 +0,0 @@ - - - - - - - - Rollup Visualizer - - - -
- - - - - From 22b795bb3a1b44acbaa26485bdee8564c1d03883 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 30 Jun 2025 01:01:39 +0000 Subject: [PATCH 58/58] Auto-generated commit --- .editorconfig | 180 - .eslintrc.js | 1 - .gitattributes | 66 - .github/.keepalive | 1 - .github/PULL_REQUEST_TEMPLATE.md | 7 - .github/workflows/benchmark.yml | 64 - .github/workflows/cancel.yml | 57 - .github/workflows/close_pull_requests.yml | 54 - .github/workflows/examples.yml | 64 - .github/workflows/npm_downloads.yml | 112 - .github/workflows/productionize.yml | 794 --- .github/workflows/publish.yml | 252 - .github/workflows/test.yml | 99 - .github/workflows/test_bundles.yml | 186 - .github/workflows/test_coverage.yml | 133 - .github/workflows/test_install.yml | 85 - .github/workflows/test_published_package.yml | 105 - .gitignore | 194 - .npmignore | 229 - .npmrc | 31 - CHANGELOG.md | 188 - CITATION.cff | 30 - CODE_OF_CONDUCT.md | 3 - CONTRIBUTING.md | 3 - Makefile | 534 -- README.md | 53 +- SECURITY.md | 5 - benchmark/benchmark.js | 108 - benchmark/python/numpy/benchmark.py | 116 - branches.md | 56 - dist/index.d.ts | 3 - dist/index.js | 5 - dist/index.js.map | 7 - docs/repl.txt | 23 - docs/types/test.ts | 48 - examples/index.js | 59 - docs/types/index.d.ts => index.d.ts | 2 +- index.mjs | 4 + index.mjs.map | 1 + lib/index.js | 50 - lib/main.js | 66 - package.json | 72 +- stats.html | 4842 ++++++++++++++++++ test/dist/test.js | 33 - test/test.js | 450 -- 45 files changed, 4872 insertions(+), 4603 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 benchmark/python/numpy/benchmark.py 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 (93%) 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 4c06465..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2025-06-30T00:49:24.086Z diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 77f409c..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/to-array) 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 bea7e4a..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/to-array) 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 5ab7164..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: '10 10 * * 0' - - # 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 + + ```
@@ -192,7 +183,7 @@ for ( i = 0; i < 20; i++ ) { ## 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]. @@ -255,13 +246,13 @@ Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors]. [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/ndarray-to-array/main/LICENSE -[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor +[@stdlib/ndarray/ctor]: https://github.com/stdlib-js/ndarray-ctor/tree/esm -[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array +[@stdlib/ndarray/array]: https://github.com/stdlib-js/ndarray-array/tree/esm -[@stdlib/ndarray/to-json]: https://github.com/stdlib-js/ndarray-to-json +[@stdlib/ndarray/to-json]: https://github.com/stdlib-js/ndarray-to-json/tree/esm diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 9702d4c..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,5 +0,0 @@ -# Security - -> Policy for reporting security vulnerabilities. - -See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security). diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js deleted file mode 100644 index d5f62ed..0000000 --- a/benchmark/benchmark.js +++ /dev/null @@ -1,108 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArrayArray = require( '@stdlib/assert-is-array-array' ); -var shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var numel = require( '@stdlib/ndarray-base-numel' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var pkg = require( './../package.json' ).name; -var ndarray2array = require( './../lib' ); - - -// MAIN // - -bench( pkg+':order=row-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'row-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); - -bench( pkg+':order=column-major', function benchmark( b ) { - var strides; - var buffer; - var offset; - var order; - var shape; - var len; - var arr; - var out; - var i; - - shape = [ 10, 10, 10 ]; - order = 'column-major'; - len = numel( shape ); - buffer = zeroTo( len ); - strides = shape2strides( shape, order ); - offset = strides2offset( shape, strides ); - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - - b.tic(); - for ( i = 0; i < b.iterations; i++ ) { - out = ndarray2array( arr ); - if ( out.length !== shape[ 0 ] ) { - b.fail( 'should have expected length' ); - } - } - b.toc(); - if ( - !isArrayArray( out ) || - !isArrayArray( out[ 0 ] ) - ) { - b.fail( 'should return an array of arrays' ); - } - b.pass( 'benchmark finished' ); - b.end(); -}); diff --git a/benchmark/python/numpy/benchmark.py b/benchmark/python/numpy/benchmark.py deleted file mode 100644 index b889de6..0000000 --- a/benchmark/python/numpy/benchmark.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env python -# -# @license Apache-2.0 -# -# Copyright (c) 2023 The Stdlib Authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Benchmark numpy.ndarray.tolist.""" - -from __future__ import print_function -import timeit - -NAME = "to-array" -REPEATS = 3 -ITERATIONS = 10000 -COUNT = [0] # use a list to allow modification within nested scopes - - -def print_version(): - """Print the TAP version.""" - print("TAP version 13") - - -def print_summary(total, passing): - """Print the benchmark summary. - - # Arguments - - * `total`: total number of tests - * `passing`: number of passing tests - - """ - print("#") - print("1.." + str(total)) # TAP plan - print("# total " + str(total)) - print("# pass " + str(passing)) - print("#") - print("# ok") - - -def print_results(iterations, elapsed): - """Print benchmark results. - - # Arguments - - * `iterations`: number of iterations - * `elapsed`: elapsed time (in seconds) - - # Examples - - ``` python - python> print_results(100000, 0.131009101868) - ``` - """ - rate = iterations / elapsed - - print(" ---") - print(" iterations: " + str(iterations)) - print(" elapsed: " + str(elapsed)) - print(" rate: " + str(rate)) - print(" ...") - - -def benchmark(name, setup, stmt, iterations): - """Run the benchmark and print benchmark results. - - # Arguments - - * `name`: benchmark name (suffix) - * `setup`: benchmark setup - * `stmt`: statement to benchmark - * `iterations`: number of iterations - - # Examples - - ``` python - python> benchmark("::random", "from random import random;", "y = random()", 1000000) - ``` - """ - t = timeit.Timer(stmt, setup=setup) - - print_version() - - i = 0 - while i < REPEATS: - print("# python::numpy::" + NAME + name) - COUNT[0] += 1 - elapsed = t.timeit(number=iterations) - print_results(iterations, elapsed) - print("ok " + str(COUNT[0]) + " benchmark finished") - i += 1 - - -def main(): - """Run the benchmarks.""" - name = "" - setup = "import numpy as np; from random import random; x = np.zeros((10,10,10))" - stmt = "y = x.tolist()" - benchmark(name, setup, stmt, ITERATIONS) - - print_summary(COUNT[0], COUNT[0]) - - -if __name__ == "__main__": - main() diff --git a/branches.md b/branches.md deleted file mode 100644 index beca644..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/to-array" -%% click B href "https://github.com/stdlib-js/ndarray-to-array/tree/main" -%% click C href "https://github.com/stdlib-js/ndarray-to-array/tree/production" -%% click D href "https://github.com/stdlib-js/ndarray-to-array/tree/esm" -%% click E href "https://github.com/stdlib-js/ndarray-to-array/tree/deno" -%% click F href "https://github.com/stdlib-js/ndarray-to-array/tree/umd" -``` - -[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/ndarray/to-array -[production-url]: https://github.com/stdlib-js/ndarray-to-array/tree/production -[deno-url]: https://github.com/stdlib-js/ndarray-to-array/tree/deno -[deno-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/deno/README.md -[umd-url]: https://github.com/stdlib-js/ndarray-to-array/tree/umd -[umd-readme]: https://github.com/stdlib-js/ndarray-to-array/blob/umd/README.md -[esm-url]: https://github.com/stdlib-js/ndarray-to-array/tree/esm -[esm-readme]: https://github.com/stdlib-js/ndarray-to-array/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 e33cc6e..0000000 --- a/dist/index.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -/// -import ndarray2array from '../docs/types/index'; -export = ndarray2array; \ No newline at end of file diff --git a/dist/index.js b/dist/index.js deleted file mode 100644 index 11d14c3..0000000 --- a/dist/index.js +++ /dev/null @@ -1,5 +0,0 @@ -"use strict";var i=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var t=i(function(c,a){ -var u=require('@stdlib/assert-is-ndarray-like/dist'),n=require('@stdlib/ndarray-base-to-array/dist'),s=require('@stdlib/ndarray-strides/dist'),v=require('@stdlib/ndarray-offset/dist'),q=require('@stdlib/ndarray-shape/dist'),d=require('@stdlib/ndarray-order/dist'),o=require('@stdlib/ndarray-data-buffer/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist');function g(r){if(!u(r))throw new TypeError(y('1dfDv',r));return n(o(r),q(r),s(r),v(r),d(r))}a.exports=g -});var f=t();module.exports=f; -/** @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 9656dbe..0000000 --- a/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isndarrayLike = require( '@stdlib/assert-is-ndarray-like' );\nvar toArray = require( '@stdlib/ndarray-base-to-array' );\nvar getStrides = require( '@stdlib/ndarray-strides' );\nvar getOffset = require( '@stdlib/ndarray-offset' );\nvar getShape = require( '@stdlib/ndarray-shape' );\nvar getOrder = require( '@stdlib/ndarray-order' );\nvar getData = require( '@stdlib/ndarray-data-buffer' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Convert an ndarray to a generic array (which may include nested arrays).\n*\n* @module @stdlib/ndarray-to-array\n*\n* @example\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var ndarray2array = require( '@stdlib/ndarray-to-array' );\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n* // returns \n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\n\n// MODULES //\n\nvar ndarray2array = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = ndarray2array;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAU,QAAS,+BAAgC,EACnDC,EAAa,QAAS,yBAA0B,EAChDC,EAAY,QAAS,wBAAyB,EAC9CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAW,QAAS,uBAAwB,EAC5CC,EAAU,QAAS,6BAA8B,EACjDC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAeC,EAAI,CAC3B,GAAK,CAACT,EAAeS,CAAE,EACtB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAE,CAAE,EAE7F,OAAOR,EAASK,EAASG,CAAE,EAAGL,EAAUK,CAAE,EAAGP,EAAYO,CAAE,EAAGN,EAAWM,CAAE,EAAGJ,EAAUI,CAAE,CAAE,CAC7F,CAKAV,EAAO,QAAUS,ICrBjB,IAAIE,EAAgB,IAKpB,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isndarrayLike", "toArray", "getStrides", "getOffset", "getShape", "getOrder", "getData", "format", "ndarray2array", "x", "ndarray2array"] -} diff --git a/docs/repl.txt b/docs/repl.txt deleted file mode 100644 index e250c53..0000000 --- a/docs/repl.txt +++ /dev/null @@ -1,23 +0,0 @@ - -{{alias}}( x ) - Converts an ndarray to a generic array. - - Parameters - ---------- - x: ndarray - Input array. - - Returns - ------- - out: Array|Array - Generic array (which may include nested arrays). - - Examples - -------- - > var arr = {{alias:@stdlib/ndarray/array}}( [ [ 1, 2 ], [ 3, 4 ] ] ); - > var out = {{alias}}( arr ) - [ [ 1, 2 ], [ 3, 4 ] ] - - See Also - -------- - diff --git a/docs/types/test.ts b/docs/types/test.ts deleted file mode 100644 index 85d256a..0000000 --- a/docs/types/test.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT 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 array = require( '@stdlib/ndarray-array' ); -import ndarray2array = require( './index' ); - - -// TESTS // - -// The function returns an array... -{ - ndarray2array( array( [ [ 1, 2 ], [ 3, 4 ] ] ) ); // $ExpectType any[] -} - -// The compiler throws an error if the function is provided a first argument which is not an ndarray... -{ - ndarray2array( 123 ); // $ExpectError - ndarray2array( true ); // $ExpectError - ndarray2array( false ); // $ExpectError - ndarray2array( null ); // $ExpectError - ndarray2array( undefined ); // $ExpectError - ndarray2array( [ 1, 2 ] ); // $ExpectError - ndarray2array( {} ); // $ExpectError - ndarray2array( ( x: number ): number => x ); // $ExpectError -} - -// The compiler throws an error if the function is provided an unsupported number of arguments... -{ - const arr = array( [ [ 1, 2 ], [ 3, 4 ] ] ); - - ndarray2array(); // $ExpectError - ndarray2array( arr, {} ); // $ExpectError -} diff --git a/examples/index.js b/examples/index.js deleted file mode 100644 index f9f0b60..0000000 --- a/examples/index.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR 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 shape2strides = require( '@stdlib/ndarray-base-shape2strides' ); -var strides2offset = require( '@stdlib/ndarray-base-strides2offset' ); -var discreteUniform = require( '@stdlib/random-base-discrete-uniform' ); -var zeroTo = require( '@stdlib/array-base-zero-to' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - -// Create a data buffer: -var buffer = zeroTo( 27 ); - -// Specify array meta data: -var shape = [ 3, 3, 3 ]; -var order = 'column-major'; -var ndims = shape.length; - -// Compute array meta data: -var strides = shape2strides( shape, order ); -var offset = strides2offset( shape, strides ); - -// Print array information: -console.log( '' ); -console.log( 'Dims: %s', shape.join( 'x' ) ); - -// Randomly flip strides and convert an ndarray to a nested array... -var arr; -var i; -var j; -for ( i = 0; i < 20; i++ ) { - j = discreteUniform( 0, ndims-1 ); - strides[ j ] *= -1; - offset = strides2offset( shape, strides ); - - console.log( '' ); - console.log( 'Strides: %s', strides.join( ',' ) ); - console.log( 'Offset: %d', offset ); - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - console.log( JSON.stringify( ndarray2array( arr ) ) ); -} diff --git a/docs/types/index.d.ts b/index.d.ts similarity index 93% rename from docs/types/index.d.ts rename to index.d.ts index 41e22a7..a5cf41c 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..6fd14c6 --- /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/assert-is-ndarray-like@v0.2.2-esm/index.mjs";import r from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-to-array@v0.2.1-esm/index.mjs";import t from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-strides@v0.2.2-esm/index.mjs";import e from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-offset@v0.2.2-esm/index.mjs";import d from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-shape@v0.2.2-esm/index.mjs";import i from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-order@v0.2.2-esm/index.mjs";import n from"https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-data-buffer@v0.2.2-esm/index.mjs";import m from"https://cdn.jsdelivr.net/gh/stdlib-js/error-tools-fmtprodmsg@v0.2.2-esm/index.mjs";function o(o){if(!s(o))throw new TypeError(m("1dfDv",o));return r(n(o),d(o),t(o),e(o),i(o))}export{o as default}; +//# sourceMappingURL=index.mjs.map diff --git a/index.mjs.map b/index.mjs.map new file mode 100644 index 0000000..05c2dea --- /dev/null +++ b/index.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"index.mjs","sources":["../lib/main.js"],"sourcesContent":["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2023 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nimport isndarrayLike from '@stdlib/assert-is-ndarray-like';\nimport toArray from '@stdlib/ndarray-base-to-array';\nimport getStrides from '@stdlib/ndarray-strides';\nimport getOffset from '@stdlib/ndarray-offset';\nimport getShape from '@stdlib/ndarray-shape';\nimport getOrder from '@stdlib/ndarray-order';\nimport getData from '@stdlib/ndarray-data-buffer';\nimport format from '@stdlib/error-tools-fmtprodmsg';\n\n\n// MAIN //\n\n/**\n* Converts an ndarray to a generic array (which may include nested arrays).\n*\n* @param {ndarrayLike} x - input ndarray\n* @throws {TypeError} must provide an ndarray\n* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays)\n*\n* @example\n* import ndarray from '@stdlib/ndarray-ctor';\n*\n* var buffer = [ 1, 2, 3, 4 ];\n* var shape = [ 2, 2 ];\n* var order = 'row-major';\n* var strides = [ 2, 1 ];\n* var offset = 0;\n*\n* var arr = ndarray( 'generic', buffer, shape, strides, offset, order );\n*\n* var out = ndarray2array( arr );\n* // returns [ [ 1, 2 ], [ 3, 4 ] ]\n*/\nfunction ndarray2array( x ) {\n\tif ( !isndarrayLike( x ) ) {\n\t\tthrow new TypeError( format( '1dfDv', x ) );\n\t}\n\treturn toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len\n}\n\n\n// EXPORTS //\n\nexport default ndarray2array;\n"],"names":["ndarray2array","x","isndarrayLike","TypeError","format","toArray","getData","getShape","getStrides","getOffset","getOrder"],"mappings":";;muBAuDA,SAASA,EAAeC,GACvB,IAAMC,EAAeD,GACpB,MAAM,IAAIE,UAAWC,EAAQ,QAASH,IAEvC,OAAOI,EAASC,EAASL,GAAKM,EAAUN,GAAKO,EAAYP,GAAKQ,EAAWR,GAAKS,EAAUT,GACzF"} \ No newline at end of file diff --git a/lib/index.js b/lib/index.js deleted file mode 100644 index 1ab89e2..0000000 --- a/lib/index.js +++ /dev/null @@ -1,50 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -/** -* Convert an ndarray to a generic array (which may include nested arrays). -* -* @module @stdlib/ndarray-to-array -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* var ndarray2array = require( '@stdlib/ndarray-to-array' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* // returns -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ - -// MODULES // - -var ndarray2array = require( './main.js' ); - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/lib/main.js b/lib/main.js deleted file mode 100644 index 6958225..0000000 --- a/lib/main.js +++ /dev/null @@ -1,66 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var isndarrayLike = require( '@stdlib/assert-is-ndarray-like' ); -var toArray = require( '@stdlib/ndarray-base-to-array' ); -var getStrides = require( '@stdlib/ndarray-strides' ); -var getOffset = require( '@stdlib/ndarray-offset' ); -var getShape = require( '@stdlib/ndarray-shape' ); -var getOrder = require( '@stdlib/ndarray-order' ); -var getData = require( '@stdlib/ndarray-data-buffer' ); -var format = require( '@stdlib/error-tools-fmtprodmsg' ); - - -// MAIN // - -/** -* Converts an ndarray to a generic array (which may include nested arrays). -* -* @param {ndarrayLike} x - input ndarray -* @throws {TypeError} must provide an ndarray -* @returns {(EmptyArray|Array|Array)} array (which may include nested arrays) -* -* @example -* var ndarray = require( '@stdlib/ndarray-ctor' ); -* -* var buffer = [ 1, 2, 3, 4 ]; -* var shape = [ 2, 2 ]; -* var order = 'row-major'; -* var strides = [ 2, 1 ]; -* var offset = 0; -* -* var arr = ndarray( 'generic', buffer, shape, strides, offset, order ); -* -* var out = ndarray2array( arr ); -* // returns [ [ 1, 2 ], [ 3, 4 ] ] -*/ -function ndarray2array( x ) { - if ( !isndarrayLike( x ) ) { - throw new TypeError( format( '1dfDv', x ) ); - } - return toArray( getData( x ), getShape( x ), getStrides( x ), getOffset( x ), getOrder( x ) ); // eslint-disable-line max-len -} - - -// EXPORTS // - -module.exports = ndarray2array; diff --git a/package.json b/package.json index 339e8b2..7ae6df8 100644 --- a/package.json +++ b/package.json @@ -3,31 +3,8 @@ "version": "0.2.1", "description": "Convert an ndarray to a generic array.", "license": "Apache-2.0", - "author": { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - }, - "contributors": [ - { - "name": "The Stdlib Authors", - "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" - } - ], - "main": "./lib", - "directories": { - "benchmark": "./benchmark", - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "test": "make test", - "test-cov": "make test-cov", - "examples": "make examples", - "benchmark": "make benchmark" - }, + "type": "module", + "main": "./index.mjs", "homepage": "https://stdlib.io", "repository": { "type": "git", @@ -36,50 +13,6 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": { - "@stdlib/assert-is-ndarray-like": "^0.2.2", - "@stdlib/ndarray-base-to-array": "^0.2.1", - "@stdlib/ndarray-data-buffer": "^0.2.2", - "@stdlib/ndarray-offset": "^0.2.2", - "@stdlib/ndarray-order": "^0.2.2", - "@stdlib/ndarray-shape": "^0.2.2", - "@stdlib/ndarray-strides": "^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/array-complex64": "^0.3.0", - "@stdlib/assert-is-array": "^0.2.2", - "@stdlib/assert-is-array-array": "^0.2.2", - "@stdlib/complex-float32-imag": "^0.1.1", - "@stdlib/complex-float32-real": "^0.1.1", - "@stdlib/ndarray-base-numel": "^0.2.2", - "@stdlib/ndarray-base-shape2strides": "^0.2.2", - "@stdlib/ndarray-base-strides2offset": "^0.2.2", - "@stdlib/ndarray-ctor": "^0.2.2", - "@stdlib/random-base-discrete-uniform": "^0.2.1", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "istanbul": "^0.4.1", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "@stdlib/bench-harness": "^0.2.2" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], "keywords": [ "stdlib", "stdtypes", @@ -97,7 +30,6 @@ "transform", "nested" ], - "__stdlib__": {}, "funding": { "type": "opencollective", "url": "https://opencollective.com/stdlib" diff --git a/stats.html b/stats.html new file mode 100644 index 0000000..7302bb5 --- /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 696995f..0000000 --- a/test/test.js +++ /dev/null @@ -1,450 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2023 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF 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 isArray = require( '@stdlib/assert-is-array' ); -var Complex64Array = require( '@stdlib/array-complex64' ); -var realf = require( '@stdlib/complex-float32-real' ); -var imagf = require( '@stdlib/complex-float32-imag' ); -var ndarray = require( '@stdlib/ndarray-ctor' ); -var ndarray2array = require( './../lib' ); - - -// TESTS // - -tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof ndarray2array, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function throws an error if not provided an ndarray-like object', function test( t ) { - var values; - var i; - - values = [ - '5', - 5, - NaN, - true, - false, - null, - void 0, - [], - {}, - function noop() {} - ]; - for ( i = 0; i < values.length; i++ ) { - t.throws( badValue( values[ i ] ), TypeError, 'throws an error when provided ' + values[ i ] ); - } - t.end(); - - function badValue( value ) { - return function badValue() { - ndarray2array( value ); - }; - } -}); - -tape( 'the function returns an empty array if provided an ndarray', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [], [], [ 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function returns an empty array if provided an ndarray having one or more dimensions which have zero elements', function test( t ) { - var out; - var arr; - - arr = ndarray( 'generic', [ 1, 2, 3, 4 ], [ 2, 0 ], [ 0, 0 ], 0, 'row-major' ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.strictEqual( out.length, 0, 'returns an empty array' ); - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'row-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 1, 2, 3, 4, 5, 6 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=row-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'row-major'; - strides = [ -1 ]; - offset = 2; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 6 ]; - order = 'column-major'; - strides = [ -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ 6, 5, 4, 3, 2, 1 ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (1d; order=column-major; complex data type)', function test( t ) { - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - var v; - - buffer = new Complex64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); - - shape = [ 3 ]; - order = 'column-major'; - strides = [ 1 ]; - offset = 0; - - arr = ndarray( 'complex64', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - t.strictEqual( isArray( out ), true, 'returns an array' ); - - v = out[ 0 ]; - t.strictEqual( realf( v ), 1.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 2.0, 'returns expected value' ); - - v = out[ 1 ]; - t.strictEqual( realf( v ), 3.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 4.0, 'returns expected value' ); - - v = out[ 2 ]; - t.strictEqual( realf( v ), 5.0, 'returns expected value' ); - t.strictEqual( imagf( v ), 6.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'row-major'; - strides = [ 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 2 ], - [ 3, 4 ], - [ 5, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, 1 ]; - offset = 4; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 5, 6 ], - [ 3, 4 ], - [ 1, 2 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 2, -1 ]; - offset = 1; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 2, 1 ], - [ 4, 3 ], - [ 6, 5 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -2, -1 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 5 ], - [ 4, 3 ], - [ 2, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (2d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6 ]; - - shape = [ 3, 2 ]; - order = 'column-major'; - strides = [ 1, 3 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 1, 4 ], - [ 2, 5 ], - [ 3, 6 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, 3 ]; - offset = 2; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 3, 6 ], - [ 2, 5 ], - [ 1, 4 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ 1, -3 ]; - offset = 3; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 4, 1 ], - [ 5, 2 ], - [ 6, 3 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -3 ]; - offset = 5; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ 6, 3 ], - [ 5, 2 ], - [ 4, 1 ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=row-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'row-major'; - strides = [ 4, 2, 1 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 2 ], [ 3, 4 ] ], - [ [ 5, 6 ], [ 7, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -4, -2, -1 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 7 ], [ 6, 5 ] ], - [ [ 4, 3 ], [ 2, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function converts an ndarray to a generic array (3d; order=column-major)', function test( t ) { - var expected; - var strides; - var offset; - var buffer; - var order; - var shape; - var out; - var arr; - - buffer = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; - - shape = [ 2, 2, 2 ]; - order = 'column-major'; - strides = [ 1, 2, 4 ]; - offset = 0; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 1, 5 ], [ 3, 7 ] ], - [ [ 2, 6 ], [ 4, 8 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - strides = [ -1, -2, -4 ]; - offset = 7; - - arr = ndarray( 'generic', buffer, shape, strides, offset, order ); - out = ndarray2array( arr ); - - expected = [ - [ [ 8, 4 ], [ 6, 2 ] ], - [ [ 7, 3 ], [ 5, 1 ] ] - ]; - t.strictEqual( isArray( out ), true, 'returns an array' ); - t.deepEqual( out, expected, 'returns expected value' ); - - t.end(); -}); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy